Support diffstats in git am-style patches.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 10 Oct 2009 10:33:32 +0000 (12:33 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 10 Oct 2009 10:33:32 +0000 (12:33 +0200)
dulwich/patch.py

index 259662c53d4359ec126191d33e11834c04df7958..6693b564c6d765ade6a93f0f1dd5ebea49405830 100644 (file)
@@ -22,11 +22,8 @@ These patches are basically unified diffs with some extra metadata tacked
 on.
 """
 
-from dulwich.objects import (
-    Blob,
-    )
-
 import difflib
+import subprocess
 import time
 
 
@@ -44,8 +41,15 @@ def write_commit_patch(f, commit, contents, progress, version=None):
     f.write("Subject: [PATCH %d/%d] %s\n" % (num, total, commit.message))
     f.write("\n")
     f.write("---\n")
-    f.write("TODO: Print diffstat\n")
-    f.write("\n")
+    try:
+        p = subprocess.Popen(["diffstat"], stdout=subprocess.PIPE, 
+                             stdin=subprocess.PIPE)
+    except OSError, e:
+        pass # diffstat not available?
+    else:
+        (diffstat, _) = p.communicate(contents)
+        f.write(diffstat)
+        f.write("\n")
     f.write(contents)
     f.write("-- \n")
     if version is None: