diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-18 14:25:14 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-18 14:25:14 +0200 |
commit | 225999e9442c746333a8baa17a6dbf7341c135ca (patch) | |
tree | 82e4bdf8a59fae869bae41aa6b9b048fee2d3e09 /lib/git/objects/commit.py | |
parent | 919164df96d9f956c8be712f33a9a037b097745b (diff) | |
parent | 9acc7806d6bdb306a929c460437d3d03e5e48dcd (diff) | |
download | gitpython-225999e9442c746333a8baa17a6dbf7341c135ca.tar.gz |
Merge branch 'diffing' into improvements
* diffing:
DiffIndex implemented including test
diff: implemented raw diff parsing which appears to be able to handle possible input types, DiffIndex still requires implementation though
resolved cyclic inclusion issue by moving the Diffable interface into the diff module, which probably is the right thing to do anyway
repo: fixed untracked files function which used git-commit before, it can open vim to get a message though which makes the program appear to freeze - using git-status now
implemented diff tests, but will have to move the diff module as it needs to create objects, whose import would create a dependency cycle
Removed a few diff-related test cases that fail now as the respective method is missing - these tests have to be redone in test-diff module accordingly
added Diffable interface to objects.base, its used by Commit and Tree objects.
Fixed object bug that would cause object ids not to be resolved to sha's as this was assumed - now there is a test for it as well
Diffstat (limited to 'lib/git/objects/commit.py')
-rw-r--r-- | lib/git/objects/commit.py | 57 |
1 files changed, 2 insertions, 55 deletions
diff --git a/lib/git/objects/commit.py b/lib/git/objects/commit.py index 847f4dec..181cbb52 100644 --- a/lib/git/objects/commit.py +++ b/lib/git/objects/commit.py @@ -11,7 +11,7 @@ from tree import Tree import base import utils -class Commit(base.Object, Iterable): +class Commit(base.Object, Iterable, diff.Diffable): """ Wraps a git Commit object. @@ -176,60 +176,6 @@ class Commit(base.Object, Iterable): return self.iter_items( self.repo, self, paths, **kwargs ) - @classmethod - def diff(cls, repo, a, b=None, paths=None): - """ - Creates diffs between a tree and the index or between two trees: - - ``repo`` - is the Repo - - ``a`` - is a named commit - - ``b`` - is an optional named commit. Passing a list assumes you - wish to omit the second named commit and limit the diff to the - given paths. - - ``paths`` - is a list of paths to limit the diff to. - - Returns - git.Diff[]:: - - between tree and the index if only a is given - between two trees if a and b are given and are commits - """ - paths = paths or [] - - if isinstance(b, list): - paths = b - b = None - - if paths: - paths.insert(0, "--") - - if b: - paths.insert(0, b) - paths.insert(0, a) - text = repo.git.diff('-M', full_index=True, *paths) - return diff.Diff._list_from_string(repo, text) - - @property - def diffs(self): - """ - Returns - git.Diff[] - Diffs between this commit and its first parent or all changes if this - commit is the first commit and has no parent. - """ - if not self.parents: - d = self.repo.git.show(self.id, '-M', full_index=True, pretty='raw') - return diff.Diff._list_from_string(self.repo, d) - else: - return self.diff(self.repo, self.parents[0].id, self.id) - @property def stats(self): """ @@ -268,6 +214,7 @@ class Commit(base.Object, Iterable): if not hasattr(stream,'next'): stream = proc_or_stream.stdout + for line in stream: id = line.split()[1] assert line.split()[0] == "commit" |