mq: correctly make an empty line after description in new patches
authorMads Kiilerich <madski@unity3d.com>
Sat, 20 Sep 2014 17:06:56 +0200
changeset 22519 c87f2a5a6e49
parent 22518 52dd6e25121f
child 22520 9d4ebb75de53
mq: correctly make an empty line after description in new patches There would in some cases be an empty line between headers and the description - that does not seem right. There should also be an empty line between description and diff - but that was missing. These two mistakes would sometimes make it up for each other so we fix both at once to just show the improvement. Instead of writing an extra newline when writing a header line, write an extra line when it not is written as a part of the description but is necessary anyway.
hgext/mq.py
tests/test-mq-header-date.t
tests/test-mq-header-from.t
tests/test-mq-qnew.t
tests/test-mq-qrefresh.t
--- a/hgext/mq.py	Tue Sep 16 14:51:56 2014 -0700
+++ b/hgext/mq.py	Sat Sep 20 17:06:56 2014 +0200
@@ -1073,10 +1073,8 @@
                 if self.plainmode:
                     if user:
                         p.write("From: " + user + "\n")
-                        if not date:
-                            p.write("\n")
                     if date:
-                        p.write("Date: %d %d\n\n" % date)
+                        p.write("Date: %d %d\n" % date)
                 else:
                     p.write("# HG changeset patch\n")
                     p.write("# Parent "
@@ -1084,7 +1082,7 @@
                     if user:
                         p.write("# User " + user + "\n")
                     if date:
-                        p.write("# Date %s %s\n\n" % date)
+                        p.write("# Date %s %s\n" % date)
 
                 defaultmsg = "[mq]: %s" % patchfn
                 editor = cmdutil.getcommiteditor(editform=editform)
@@ -1117,6 +1115,8 @@
                     if nctx.description() != defaultmsg.rstrip():
                         msg = nctx.description() + "\n\n"
                         p.write(msg)
+                    elif not self.plainmode or date or user:
+                        p.write('\n')
                     if commitfiles:
                         parent = self.qparents(repo, n)
                         if inclsubs:
--- a/tests/test-mq-header-date.t	Tue Sep 16 14:51:56 2014 -0700
+++ b/tests/test-mq-header-date.t	Sat Sep 20 17:06:56 2014 +0200
@@ -243,7 +243,6 @@
   now at: 1.patch
   ==== qnew -d -m
   Date: 6 0
-  
   Three
   
   1: Three - test - 6.00
@@ -251,7 +250,6 @@
   ==== qref
   adding 3
   Date: 6 0
-  
   Three
   
   diff -r ... 3
@@ -263,7 +261,6 @@
   0: [mq]: 1.patch - test - 4.00
   ==== qref -m
   Date: 6 0
-  
   Drei
   
   diff -r ... 3
@@ -275,7 +272,6 @@
   0: [mq]: 1.patch - test - 4.00
   ==== qref -d
   Date: 7 0
-  
   Drei
   
   diff -r ... 3
@@ -287,7 +283,6 @@
   0: [mq]: 1.patch - test - 4.00
   ==== qref -d -m
   Date: 8 0
-  
   Three (again)
   
   diff -r ... 3
@@ -590,7 +585,6 @@
   # HG changeset patch
   # Parent 
   # Date 6 0
-  
   Three
   
   1: Three - test - 6.00
@@ -600,7 +594,6 @@
   # HG changeset patch
   # Parent 
   # Date 6 0
-  
   Three
   
   diff -r ... 3
@@ -614,7 +607,6 @@
   # HG changeset patch
   # Parent 
   # Date 6 0
-  
   Drei
   
   diff -r ... 3
@@ -628,7 +620,6 @@
   # HG changeset patch
   # Parent 
   # Date 7 0
-  
   Drei
   
   diff -r ... 3
@@ -642,7 +633,6 @@
   # HG changeset patch
   # Parent 
   # Date 8 0
-  
   Three (again)
   
   diff -r ... 3
--- a/tests/test-mq-header-from.t	Tue Sep 16 14:51:56 2014 -0700
+++ b/tests/test-mq-header-from.t	Sat Sep 20 17:06:56 2014 +0200
@@ -176,7 +176,6 @@
   0: [mq]: 1.patch - mary
   ==== qnew -U -m
   From: test
-  
   Three
   
   2: Three - test
@@ -185,7 +184,6 @@
   ==== qref
   adding 3
   From: test
-  
   Three
   
   diff -r ... 3
@@ -198,7 +196,6 @@
   0: [mq]: 1.patch - mary
   ==== qref -m
   From: test
-  
   Drei
   
   diff -r ... 3
@@ -211,7 +208,6 @@
   0: [mq]: 1.patch - mary
   ==== qref -u
   From: mary
-  
   Drei
   
   diff -r ... 3
@@ -224,7 +220,6 @@
   0: [mq]: 1.patch - mary
   ==== qref -u -m
   From: maria
-  
   Three (again)
   
   diff -r ... 3
@@ -406,6 +401,7 @@
   # HG changeset patch
   # Parent 
   # User test
+  
   0: [mq]: 1.patch - test
   ==== qref
   adding 1
@@ -690,6 +686,7 @@
   # HG changeset patch
   # Parent 
   # User test
+  
   0: [mq]: 1.patch - test
   ==== qref
   adding 1
--- a/tests/test-mq-qnew.t	Tue Sep 16 14:51:56 2014 -0700
+++ b/tests/test-mq-qnew.t	Sat Sep 20 17:06:56 2014 +0200
@@ -209,6 +209,7 @@
   M d/b
   # HG changeset patch
   # Parent 
+  
   diff --git a/d/b b/d/b
   --- a/d/b
   +++ b/d/b
@@ -219,10 +220,12 @@
   # HG changeset patch
   # Parent 
   # User blue
+  
   % qnew -e -u with no username configured
   # HG changeset patch
   # Parent 
   # User chartreuse
+  
   % fail when trying to import a merge
   adding a
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -337,6 +340,7 @@
   $ cat ".hg/patches/patch "
   # HG changeset patch
   # Parent 0000000000000000000000000000000000000000
+  
 
   $ cd ..
 
--- a/tests/test-mq-qrefresh.t	Tue Sep 16 14:51:56 2014 -0700
+++ b/tests/test-mq-qrefresh.t	Sat Sep 20 17:06:56 2014 +0200
@@ -508,6 +508,7 @@
   $ cat .hg/patches/a
   # HG changeset patch
   # Parent 0000000000000000000000000000000000000000
+  
   diff --git a/a b/a
   new file mode 100644
   $ hg qpush
@@ -522,6 +523,7 @@
   $ cat .hg/patches/a
   # HG changeset patch
   # Parent 0000000000000000000000000000000000000000
+  
   diff --git a/a b/a
   new file mode 100644
   $ cd ..