summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2009-10-21 10:03:56 +0200
committerSebastian Thiel <byronimo@gmail.com>2009-10-21 10:03:56 +0200
commita7f52745c95e5dd673a79a2281ccd7463ce00ffa (patch)
treec13b8b0d213d2d91e237a1de86e73a8fa9bb95f2
parent047b210d6b9ae0b65a2aee0fcfb6858c6dc01bf9 (diff)
downloadgitpython-a7f52745c95e5dd673a79a2281ccd7463ce00ffa.tar.gz
Added info about 0.1.7 release changes
reverted 19533ffadbcc959f12bf51488cf66f0715bec4c1 as it would introduce an API change
-rw-r--r--CHANGES18
-rw-r--r--lib/git/diff.py55
-rw-r--r--test/git/test_commit.py55
3 files changed, 51 insertions, 77 deletions
diff --git a/CHANGES b/CHANGES
index dbae15de..c82a3071 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,15 +4,19 @@ CHANGES
0.1.7
=======
+This is a bugfix release and the last of its kind in 0.1.X, as 0.2.X will receive
+a major redesign that will change the API.
+
+Bugfixes
+--------
+* Paths in Tree objects can now handle whitespace
+* Blob.blame was returning incorrect results which has been fixed.
+
General
-------
-* See changes in Diff class as your client code needs adjustments to work with it
-
-Diff
-----
-* Members a a_commit and b_commit renamed to a_blob and b_blob - they are populated
- with Blob objects if possible
-* Members a_path and b_path removed as this information is kept in the blobs
+* The test suite now supports Mock 0.5 and above. The transition between Mock 0.4
+ 0.5 changed the API which required adjustments.
+* Many small enhancements done to the method documentation
0.1.6
diff --git a/lib/git/diff.py b/lib/git/diff.py
index 44f55602..0216e061 100644
--- a/lib/git/diff.py
+++ b/lib/git/diff.py
@@ -5,44 +5,28 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
import re
-import blob
+import commit
class Diff(object):
"""
A Diff contains diff information between two commits.
-
- It contains two sides a and b of the diff, members are prefixed with
- "a" and "b" respectively to inidcate that.
-
- Diffs keep information about the changed blob objects, the file mode, renames,
- deletions and new files.
-
- There are a few cases where None has to be expected as member variable value:
-
- ``New File``::
-
- a_mode is None
- a_blob is None
-
- ``Deleted File``::
-
- b_mode is None
- b_blob is NOne
"""
- def __init__(self, repo, a_path, b_path, a_blob, b_blob, a_mode,
+ def __init__(self, repo, a_path, b_path, a_commit, b_commit, a_mode,
b_mode, new_file, deleted_file, rename_from,
rename_to, diff):
self.repo = repo
+ self.a_path = a_path
+ self.b_path = b_path
- if not a_blob or re.search(r'^0{40}$', a_blob):
- self.a_blob = None
+ if not a_commit or re.search(r'^0{40}$', a_commit):
+ self.a_commit = None
else:
- self.a_blob = blob.Blob(repo, id=a_blob, mode=a_mode, name=a_path)
- if not b_blob or re.search(r'^0{40}$', b_blob):
- self.b_blob = None
+ self.a_commit = commit.Commit(repo, id=a_commit)
+ if not b_commit or re.search(r'^0{40}$', b_commit):
+ self.b_commit = None
else:
- self.b_blob = blob.Blob(repo, id=b_blob, mode=b_mode, name=b_path)
+ self.b_commit = commit.Commit(repo, id=b_commit)
self.a_mode = a_mode
self.b_mode = b_mode
@@ -55,17 +39,6 @@ class Diff(object):
@classmethod
def list_from_string(cls, repo, text):
- """
- Create a new diff object from the given text
- ``repo``
- is the repository we are operating on - it is required
-
- ``text``
- result of 'git diff' between two commits or one commit and the index
-
- Returns
- git.Diff[]
- """
diffs = []
diff_header = re.compile(r"""
@@ -78,8 +51,8 @@ class Diff(object):
^new[ ]mode[ ](?P<new_mode>\d+)(?:\n|$))?
(?:^new[ ]file[ ]mode[ ](?P<new_file_mode>.+)(?:\n|$))?
(?:^deleted[ ]file[ ]mode[ ](?P<deleted_file_mode>.+)(?:\n|$))?
- (?:^index[ ](?P<a_blob>[0-9A-Fa-f]+)
- \.\.(?P<b_blob>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))?
+ (?:^index[ ](?P<a_commit>[0-9A-Fa-f]+)
+ \.\.(?P<b_commit>[0-9A-Fa-f]+)[ ]?(?P<b_mode>.+)?(?:\n|$))?
""", re.VERBOSE | re.MULTILINE).match
for diff in ('\n' + text).split('\ndiff --git')[1:]:
@@ -87,10 +60,10 @@ class Diff(object):
a_path, b_path, similarity_index, rename_from, rename_to, \
old_mode, new_mode, new_file_mode, deleted_file_mode, \
- a_blob, b_blob, b_mode = header.groups()
+ a_commit, b_commit, b_mode = header.groups()
new_file, deleted_file = bool(new_file_mode), bool(deleted_file_mode)
- diffs.append(Diff(repo, a_path, b_path, a_blob, b_blob,
+ diffs.append(Diff(repo, a_path, b_path, a_commit, b_commit,
old_mode or deleted_file_mode, new_mode or new_file_mode or b_mode,
new_file, deleted_file, rename_from, rename_to, diff[header.end():]))
diff --git a/test/git/test_commit.py b/test/git/test_commit.py
index c36d0c72..3e37a7a4 100644
--- a/test/git/test_commit.py
+++ b/test/git/test_commit.py
@@ -37,19 +37,18 @@ class TestCommit(object):
assert_equal(15, len(diffs))
- assert_equal('.gitignore', diffs[0].a_blob.name)
- assert_equal('.gitignore', diffs[0].b_blob.name)
- assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_blob.id)
- assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_blob.id)
- assert_equal('100644', diffs[0].b_blob.mode)
+ assert_equal('.gitignore', diffs[0].a_path)
+ assert_equal('.gitignore', diffs[0].b_path)
+ assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_commit.id)
+ assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_commit.id)
+ assert_equal('100644', diffs[0].b_mode)
assert_equal(False, diffs[0].new_file)
assert_equal(False, diffs[0].deleted_file)
assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs[0].diff)
- assert_equal('lib/grit/actor.rb', diffs[5].b_blob.name)
- assert_equal(None, diffs[5].a_blob)
- assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id)
- assert_equal( None, diffs[5].a_mode )
+ assert_equal('lib/grit/actor.rb', diffs[5].a_path)
+ assert_equal(None, diffs[5].a_commit)
+ assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_commit.id)
assert_equal(True, diffs[5].new_file)
assert_true(git.called)
@@ -89,7 +88,7 @@ class TestCommit(object):
diffs = Commit.diff(self.repo, '59ddc32', ['lib'])
assert_equal(1, len(diffs))
- assert_equal('lib/grit/diff.rb', diffs[0].a_blob.name)
+ assert_equal('lib/grit/diff.rb', diffs[0].a_path)
assert_true(git.called)
assert_equal(git.call_args, (('diff', '-M', '59ddc32', '--', 'lib'), {'full_index': True}))
@@ -101,7 +100,7 @@ class TestCommit(object):
diffs = Commit.diff(self.repo, '59ddc32', '13d27d5', ['lib'])
assert_equal(1, len(diffs))
- assert_equal('lib/grit/commit.rb', diffs[0].a_blob.name)
+ assert_equal('lib/grit/commit.rb', diffs[0].a_path)
assert_true(git.called)
assert_equal(git.call_args, (('diff', '-M', '59ddc32', '13d27d5', '--', 'lib'), {'full_index': True}))
@@ -115,18 +114,18 @@ class TestCommit(object):
assert_equal(15, len(diffs))
- assert_equal('.gitignore', diffs[0].a_blob.name)
- assert_equal('.gitignore', diffs[0].b_blob.name)
- assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_blob.id)
- assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_blob.id)
- assert_equal('100644', diffs[0].b_blob.mode)
+ assert_equal('.gitignore', diffs[0].a_path)
+ assert_equal('.gitignore', diffs[0].b_path)
+ assert_equal('4ebc8aea50e0a67e000ba29a30809d0a7b9b2666', diffs[0].a_commit.id)
+ assert_equal('2dd02534615434d88c51307beb0f0092f21fd103', diffs[0].b_commit.id)
+ assert_equal('100644', diffs[0].b_mode)
assert_equal(False, diffs[0].new_file)
assert_equal(False, diffs[0].deleted_file)
assert_equal("--- a/.gitignore\n+++ b/.gitignore\n@@ -1 +1,2 @@\n coverage\n+pkg", diffs[0].diff)
- assert_equal('lib/grit/actor.rb', diffs[5].b_blob.name)
- assert_equal(None, diffs[5].a_blob)
- assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_blob.id)
+ assert_equal('lib/grit/actor.rb', diffs[5].a_path)
+ assert_equal(None, diffs[5].a_commit)
+ assert_equal('f733bce6b57c0e5e353206e692b0e3105c2527f4', diffs[5].b_commit.id)
assert_equal(True, diffs[5].new_file)
assert_true(git.called)
@@ -145,17 +144,18 @@ class TestCommit(object):
assert_equal(10, len(diffs))
- assert_equal('History.txt', diffs[0].b_blob.name)
- assert_equal(None, diffs[0].a_blob)
- assert_equal('100644', diffs[0].b_blob.mode)
- assert_equal('81d2c27608b352814cbe979a6acd678d30219678', diffs[0].b_blob.id)
+ assert_equal('History.txt', diffs[0].a_path)
+ assert_equal('History.txt', diffs[0].b_path)
+ assert_equal(None, diffs[0].a_commit)
+ assert_equal('100644', diffs[0].b_mode)
+ assert_equal('81d2c27608b352814cbe979a6acd678d30219678', diffs[0].b_commit.id)
assert_equal(True, diffs[0].new_file)
assert_equal(False, diffs[0].deleted_file)
assert_equal("--- /dev/null\n+++ b/History.txt\n@@ -0,0 +1,5 @@\n+== 1.0.0 / 2007-10-09\n+\n+* 1 major enhancement\n+ * Birthday!\n+", diffs[0].diff)
- assert_equal('lib/grit.rb', diffs[5].b_blob.name)
- assert_equal(None, diffs[5].a_blob)
- assert_equal('32cec87d1e78946a827ddf6a8776be4d81dcf1d1', diffs[5].b_blob.id)
+ assert_equal('lib/grit.rb', diffs[5].a_path)
+ assert_equal(None, diffs[5].a_commit)
+ assert_equal('32cec87d1e78946a827ddf6a8776be4d81dcf1d1', diffs[5].b_commit.id)
assert_equal(True, diffs[5].new_file)
assert_true(git.called)
@@ -181,10 +181,7 @@ class TestCommit(object):
commit.__bake_it__()
diffs = commit.diffs
- # in case of mode-only changes, there is no blob
assert_equal(23, len(diffs))
- assert_equal(None, diffs[0].a_blob)
- assert_equal(None, diffs[0].b_blob)
assert_equal('100644', diffs[0].a_mode)
assert_equal('100755', diffs[0].b_mode)