diff options
Diffstat (limited to 'git/cmd.py')
-rw-r--r-- | git/cmd.py | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -213,6 +213,17 @@ def handle_process_output(process, stdout_handler, stderr_handler, finalizer): def dashify(string): return string.replace('_', '-') + + +def slots_to_dict(self, exclude=()): + return dict((s, getattr(self, s)) for s in self.__slots__ if s not in exclude) + + +def dict_to_slots_and__excluded_are_none(self, d, excluded=()): + for k, v in d.items(): + setattr(self, k, v) + for k in excluded: + setattr(self, k, None) ## -- End Utilities -- @} @@ -235,7 +246,15 @@ class Git(LazyMixin): """ __slots__ = ("_working_dir", "cat_file_all", "cat_file_header", "_version_info", "_git_options", "_environment") - + + _excluded_ = ('cat_file_all', 'cat_file_header', '_version_info') + + def __getstate__(self): + return slots_to_dict(self, exclude=self._excluded_) + + def __setstate__(self, d): + dict_to_slots_and__excluded_are_none(self, d, excluded=self._excluded_) + # CONFIGURATION # The size in bytes read from stdout when copying git's output to another stream max_chunk_size = 1024 * 64 |