[PATCH 1 of 8] mq: correctly make an empty line after description in new patches
Mads Kiilerich
mads at kiilerich.com
Tue Sep 23 20:00:02 CDT 2014
# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1411225616 -7200
# Sat Sep 20 17:06:56 2014 +0200
# Node ID 88ed3d2d9014f7b4bc102292db514c4397c72d2e
# Parent fa3181323c0aa9b2d2c2f81a7d68d57bd3a7a515
mq: correctly make an empty line after description in new patches
There would in somecases be an empty line between headers and the description -
that do 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.
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1073,10 +1073,8 @@ class queue(object):
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 @@ class queue(object):
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 @@ class queue(object):
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:
diff --git a/tests/test-mq-header-date.t b/tests/test-mq-header-date.t
--- a/tests/test-mq-header-date.t
+++ b/tests/test-mq-header-date.t
@@ -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
diff --git a/tests/test-mq-header-from.t b/tests/test-mq-header-from.t
--- a/tests/test-mq-header-from.t
+++ b/tests/test-mq-header-from.t
@@ -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
diff --git a/tests/test-mq-qnew.t b/tests/test-mq-qnew.t
--- a/tests/test-mq-qnew.t
+++ b/tests/test-mq-qnew.t
@@ -209,6 +209,7 @@ hg headers
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 headers
# 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 @@ Test handling default message with the p
$ cat ".hg/patches/patch "
# HG changeset patch
# Parent 0000000000000000000000000000000000000000
+
$ cd ..
diff --git a/tests/test-mq-qrefresh.t b/tests/test-mq-qrefresh.t
--- a/tests/test-mq-qrefresh.t
+++ b/tests/test-mq-qrefresh.t
@@ -508,6 +508,7 @@ but only after writing the bad name into
$ 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 @@ but only after writing the bad name into
$ cat .hg/patches/a
# HG changeset patch
# Parent 0000000000000000000000000000000000000000
+
diff --git a/a b/a
new file mode 100644
$ cd ..
More information about the Mercurial-devel
mailing list