diff options
author | masklinn <github.com@masklinn.net> | 2014-03-10 16:14:50 +0100 |
---|---|---|
committer | masklinn <github.com@masklinn.net> | 2014-03-10 16:14:50 +0100 |
commit | 7da2dec0262c803cf8f9814c49f8fb4c6b899b52 (patch) | |
tree | 1b417e6db3d1efb846e7bb2ad2b80c7754a1f531 | |
parent | 203d9c4f930f841bd06f7830874aa96d748eeebb (diff) | |
download | python-fastimport-git-7da2dec0262c803cf8f9814c49f8fb4c6b899b52.tar.gz |
Add copy method to CommitCommand
Allows easily creating a modified version of an existing commit without having
to modify the existing object in-place
-rw-r--r-- | fastimport/commands.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fastimport/commands.py b/fastimport/commands.py index 0a0fce5..7ddf0fd 100644 --- a/fastimport/commands.py +++ b/fastimport/commands.py @@ -142,6 +142,13 @@ class CommitCommand(ImportCommand): else: self.id = ':%s' % mark + def copy(self, **kwargs): + fields = dict((k, v) for k, v in self.__dict__.iteritems() + if k != 'id' + if not k.startswith('_')) + fields.update(kwargs) + return CommitCommand(**fields) + def __repr__(self): return self.to_string(include_file_contents=True) |