* Deal with capabilities required by the client, even if they
can not be disabled in the server. (Dave Borowitz)
+ * Fix trailing newlines in generated patch files.
+ (Jelmer Vernooij)
+
FEATURES
* Add include-tag capability to server. (Dave Borowitz)
BUG FIXES
- * Support custom fields in commits.
+ * Support custom fields in commits (readonly). (Jelmer Vernooij)
* Improved ref handling. (Dave Borowitz)
FEATURES
- * Add ObjectStore.iter_tree_contents()
+ * Add ObjectStore.iter_tree_contents(). (Jelmer Vernooij)
- * Add Index.changes_from_tree()
+ * Add Index.changes_from_tree(). (Jelmer Vernooij)
- * Add ObjectStore.tree_changes()
+ * Add ObjectStore.tree_changes(). (Jelmer Vernooij)
* Add functionality for writing patches in dulwich.patch.
+ (Jelmer Vernooij)
0.4.0 2009-10-07
on.
"""
-import difflib
+from difflib import SequenceMatcher
import subprocess
import time
return commit.message.splitlines()[0].replace(" ", "-")
+def unified_diff(a, b, fromfile='', tofile='', n=3, lineterm='\n'):
+ """difflib.unified_diff that doesn't write any dates or trailing spaces.
+
+ Based on the same function in Python2.6.5-rc2's difflib.py
+ """
+ started = False
+ for group in SequenceMatcher(None, a, b).get_grouped_opcodes(3):
+ if not started:
+ yield '--- %s\n' % fromfile
+ yield '+++ %s\n' % tofile
+ started = True
+ i1, i2, j1, j2 = group[0][1], group[-1][2], group[0][3], group[-1][4]
+ yield "@@ -%d,%d +%d,%d @@\n" % (i1+1, i2-i1, j1+1, j2-j1)
+ for tag, i1, i2, j1, j2 in group:
+ if tag == 'equal':
+ for line in a[i1:i2]:
+ yield ' ' + line
+ continue
+ if tag == 'replace' or tag == 'delete':
+ for line in a[i1:i2]:
+ yield '-' + line
+ if tag == 'replace' or tag == 'insert':
+ for line in b[j1:j2]:
+ yield '+' + line
+
+
def write_blob_diff(f, (old_path, old_mode, old_blob),
(new_path, new_mode, new_blob)):
"""Write diff file header.
blob_id(old_blob), blob_id(new_blob), new_mode))
old_contents = lines(old_blob)
new_contents = lines(new_blob)
- f.writelines(difflib.unified_diff(old_contents, new_contents,
+ f.writelines(unified_diff(old_contents, new_contents,
old_path, new_path))