| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,7 @@ Changelog | |||
| 6 | 6 | ============================= | |
| 7 | 7 | ||
| 8 | 8 | * `tag.commit` will now resolve commits deeply. | |
| 9 | + * `Repo` objects can now be pickled, which helps with multi-processing. | ||
| 9 | 10 | ||
| 10 | 11 | * `DiffIndex.iter_change_type(...)` produces better results when diffing | |
| 11 | 12 | 2.0.8 - Features and Bugfixes | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -213,6 +213,17 @@ def _deplete_buffer(fno, handler, buf_list, wg=None): | |||
| 213 | 213 | ||
| 214 | 214 | def dashify(string): | |
| 215 | 215 | return string.replace('_', '-') | |
| 216 | + | ||
| 217 | + | ||
| 218 | + def slots_to_dict(self, exclude=()): | ||
| 219 | + return dict((s, getattr(self, s)) for s in self.__slots__ if s not in exclude) | ||
| 220 | + | ||
| 221 | + | ||
| 222 | + def dict_to_slots_and__excluded_are_none(self, d, excluded=()): | ||
| 223 | + for k, v in d.items(): | ||
| 224 | + setattr(self, k, v) | ||
| 225 | + for k in excluded: | ||
| 226 | + setattr(self, k, None) | ||
| 216 | 227 | ||
| 217 | 228 | ## -- End Utilities -- @} | |
| 218 | 229 | ||
@@ -235,7 +246,15 @@ class Git(LazyMixin): | |||
| 235 | 246 | """ | |
| 236 | 247 | __slots__ = ("_working_dir", "cat_file_all", "cat_file_header", "_version_info", | |
| 237 | 248 | "_git_options", "_environment") | |
| 238 | - | ||
| 249 | + | ||
| 250 | + _excluded_ = ('cat_file_all', 'cat_file_header', '_version_info') | ||
| 251 | + | ||
| 252 | + def __getstate__(self): | ||
| 253 | + return slots_to_dict(self, exclude=self._excluded_) | ||
| 254 | + | ||
| 255 | + def __setstate__(self, d): | ||
| 256 | + dict_to_slots_and__excluded_are_none(self, d, excluded=self._excluded_) | ||
| 257 | + | ||
| 239 | 258 | # CONFIGURATION | |
| 240 | 259 | # The size in bytes read from stdout when copying git's output to another stream | |
| 241 | 260 | max_chunk_size = 1024 * 64 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -93,7 +93,6 @@ class Repo(object): | |||
| 93 | 93 | ||
| 94 | 94 | 'git_dir' is the .git repository directory, which is always set.""" | |
| 95 | 95 | DAEMON_EXPORT_FILE = 'git-daemon-export-ok' | |
| 96 | - __slots__ = ("working_dir", "_working_tree_dir", "git_dir", "_bare", "git", "odb") | ||
| 97 | 96 | ||
| 98 | 97 | # precompiled regex | |
| 99 | 98 | re_whitespace = re.compile(r'\s+') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,8 @@ | |||
| 4 | 4 | # | |
| 5 | 5 | # This module is part of GitPython and is released under | |
| 6 | 6 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 7 | + import pickle | ||
| 8 | + | ||
| 7 | 9 | from git.test.lib import ( | |
| 8 | 10 | patch, | |
| 9 | 11 | TestBase, | |
@@ -104,13 +106,15 @@ def test_tree_from_revision(self): | |||
| 104 | 106 | ||
| 105 | 107 | # try from invalid revision that does not exist | |
| 106 | 108 | self.failUnlessRaises(BadName, self.rorepo.tree, 'hello world') | |
| 109 | + | ||
| 110 | + def test_pickleable(self): | ||
| 111 | + pickle.loads(pickle.dumps(self.rorepo)) | ||
| 107 | 112 | ||
| 108 | 113 | def test_commit_from_revision(self): | |
| 109 | 114 | commit = self.rorepo.commit('0.1.4') | |
| 110 | 115 | assert commit.type == 'commit' | |
| 111 | 116 | assert self.rorepo.commit(commit) == commit | |
| 112 | 117 | ||
| 113 | - def test_commits(self): | ||
| 114 | 118 | mc = 10 | |
| 115 | 119 | commits = list(self.rorepo.iter_commits('0.1.6', max_count=mc)) | |
| 116 | 120 | assert len(commits) == mc | |
| Back | FazBrowse Home | New Git URL |
0 commit comments