changeset 7664:3cc74ee75b0d

diffstat: don't fail on merges First version by Alexander Solovyov <piranha@piranha.org.ua>
author Patrick Mezard <pmezard@gmail.com>
date Tue, 13 Jan 2009 20:28:06 +0200
parents b0a0eb28a933
children 950484f05f16
files mercurial/patch.py tests/test-notify tests/test-notify.out
diffstat 3 files changed, 71 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Sat Jan 17 15:25:20 2009 +0100
+++ b/mercurial/patch.py	Tue Jan 13 20:28:06 2009 +0200
@@ -1343,14 +1343,13 @@
         single(rev, seqno+1, fp)
 
 def diffstatdata(lines):
-    filename = None
+    filename, adds, removes = None, 0, 0
     for line in lines:
         if line.startswith('diff'):
             if filename:
                 yield (filename, adds, removes)
             # set numbers to 0 anyway when starting new file
-            adds = 0
-            removes = 0
+            adds, removes = 0, 0
             if line.startswith('diff --git'):
                 filename = gitre.search(line).group(1)
             else:
@@ -1360,7 +1359,8 @@
             adds += 1
         elif line.startswith('-') and not line.startswith('---'):
             removes += 1
-    yield (filename, adds, removes)
+    if filename: 
+        yield (filename, adds, removes)
 
 def diffstat(lines):
     output = []
--- a/tests/test-notify	Sat Jan 17 15:25:20 2009 +0100
+++ b/tests/test-notify	Tue Jan 13 20:28:06 2009 +0200
@@ -84,3 +84,17 @@
 hg --traceback --cwd b pull ../a 2>&1 | sed -e 's/\(Message-Id:\).*/\1/' \
   -e 's/changeset \([0-9a-f]*\) in .*/changeset \1/' \
   -e 's/^Date:.*/Date:/'
+
+echo % test merge
+cd a
+hg up -C 0
+echo a >> a
+hg ci -Am adda2 -d '2 0'
+hg merge
+hg ci -m merge -d '3 0'
+cd ..
+
+hg --traceback --cwd b pull ../a 2>&1 | sed -e 's/\(Message-Id:\).*/\1/' \
+  -e 's/changeset \([0-9a-f]*\) in .*/changeset \1/' \
+  -e 's/^Date:.*/Date:/'
+
--- a/tests/test-notify.out	Sat Jan 17 15:25:20 2009 +0100
+++ b/tests/test-notify.out	Tue Jan 13 20:28:06 2009 +0200
@@ -164,3 +164,56 @@
  a
 +a
 (run 'hg update' to get a working copy)
+% test merge
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+created new head
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(branch merge, don't forget to commit)
+pulling from ../a
+searching for changes
+adding changesets
+adding manifests
+adding file changes
+added 2 changesets with 0 changes to 1 files
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Test: foo
+Date:
+Subject: adda2
+From: test@test.com
+X-Hg-Notification: changeset 0a184ce6067f
+Message-Id:
+To: baz@test.com, foo@bar
+
+changeset 0a184ce6067f
+description:
+	adda2
+diffstat:
+
+ a |  1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+
+diffs (6 lines):
+
+diff -r cb9a9f314b8b -r 0a184ce6067f a
+--- a/a	Thu Jan 01 00:00:00 1970 +0000
++++ b/a	Thu Jan 01 00:00:02 1970 +0000
+@@ -1,1 +1,2 @@
+ a
++a
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Test: foo
+Date:
+Subject: merge
+From: test@test.com
+X-Hg-Notification: changeset 22c88b85aa27
+Message-Id:
+To: baz@test.com, foo@bar
+
+changeset 22c88b85aa27
+description:
+	merge
+(run 'hg update' to get a working copy)