mq: add parent node IDs to MQ patches on qrefresh/qnew
The goal of this patch is to add the IDs of the parents of applied MQ patches
into the patch file headers whenever qnew or qrefresh are run.
This will serve as a reminder of when the patches last applied cleanly and
will let us do more intelligent things in the future, such as:
* Resolve conflicts found when qpushing to a new location by merging
instead of simply showing rejects.
* Display better diffs of versioned MQ patches because we can tell how the
patched files have changed in the meantime.
Here are the new rules this patch introduces. They are checked in this order:
* If a patch currently has old, plain-style patch headers ("From:" and
"Date:") do not change the style or add any new headers.
* If the 'mq.plain' configuration setting is true, only plain-style
headers will be used for all MQ patches.
* qnew will initialize new patches with HG-style headers and fill in the
"# Parent" header with the appropriate parent node.
* qrefresh will refresh the "# Parent" header with the current parent of
the current patch.
--- a/hgext/mq.py Mon Feb 08 19:44:04 2010 +0100
+++ b/hgext/mq.py Sun Feb 07 10:47:54 2010 -0500
@@ -68,7 +68,7 @@
return self.rev + ':' + self.name
class patchheader(object):
- def __init__(self, pf):
+ def __init__(self, pf, plainmode=False):
def eatdiff(lines):
while lines:
l = lines[-1]
@@ -90,6 +90,7 @@
comments = []
user = None
date = None
+ parent = None
format = None
subject = None
diffstart = 0
@@ -112,6 +113,8 @@
user = line[7:]
elif line.startswith("# Date "):
date = line[7:]
+ elif line.startswith("# Parent "):
+ parent = line[9:]
elif not line.startswith("# ") and line:
message.append(line)
format = None
@@ -126,6 +129,10 @@
line.startswith("from: "))):
user = line[6:]
format = "tag"
+ elif (format != "tagdone" and (line.startswith("Date: ") or
+ line.startswith("date: "))):
+ date = line[6:]
+ format = "tag"
elif format == "tag" and line == "":
# when looking for tags (subject: from: etc) they
# end once you find a blank line in the source
@@ -148,7 +155,9 @@
self.comments = comments
self.user = user
self.date = date
+ self.parent = parent
self.haspatch = diffstart > 1
+ self.plainmode = plainmode
def setuser(self, user):
if not self.updateheader(['From: ', '# User '], user):
@@ -156,7 +165,7 @@
patchheaderat = self.comments.index('# HG changeset patch')
self.comments.insert(patchheaderat + 1, '# User ' + user)
except ValueError:
- if self._hasheader(['Date: ']):
+ if self.plainmode or self._hasheader(['Date: ']):
self.comments = ['From: ' + user] + self.comments
else:
tmp = ['# HG changeset patch', '# User ' + user, '']
@@ -169,13 +178,22 @@
patchheaderat = self.comments.index('# HG changeset patch')
self.comments.insert(patchheaderat + 1, '# Date ' + date)
except ValueError:
- if self._hasheader(['From: ']):
+ if self.plainmode or self._hasheader(['From: ']):
self.comments = ['Date: ' + date] + self.comments
else:
tmp = ['# HG changeset patch', '# Date ' + date, '']
self.comments = tmp + self.comments
self.date = date
+ def setparent(self, parent):
+ if not self.updateheader(['# Parent '], parent):
+ try:
+ patchheaderat = self.comments.index('# HG changeset patch')
+ self.comments.insert(patchheaderat + 1, '# Parent ' + parent)
+ except ValueError:
+ pass
+ self.parent = parent
+
def setmessage(self, message):
if self.comments:
self._delmsg()
@@ -245,6 +263,7 @@
self.gitmode = gitmode and 'yes' or 'no'
except error.ConfigError:
self.gitmode = ui.config('mq', 'git', 'auto').lower()
+ self.plainmode = ui.configbool('mq', 'plain', False)
@util.propertycache
def applied(self):
@@ -509,7 +528,7 @@
if n is None:
raise util.Abort(_("repo commit failed"))
try:
- ph = patchheader(mergeq.join(patch))
+ ph = patchheader(mergeq.join(patch), self.plainmode)
except:
raise util.Abort(_("unable to read %s") % patch)
@@ -639,7 +658,7 @@
pf = os.path.join(patchdir, patchname)
try:
- ph = patchheader(self.join(patchname))
+ ph = patchheader(self.join(patchname), self.plainmode)
except:
self.ui.warn(_("unable to read %s\n") % patchname)
err = 1
@@ -831,14 +850,20 @@
# if patch file write fails, abort early
p = self.opener(patchfn, "w")
try:
- if date:
+ 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)
+ else:
p.write("# HG changeset patch\n")
+ p.write("# Parent " + hex(repo[None].parents()[0].node()) + "\n")
if user:
p.write("# User " + user + "\n")
- p.write("# Date %d %d\n\n" % date)
- elif user:
- p.write("From: " + user + "\n\n")
-
+ if date:
+ p.write("# Date %s %s\n\n" % date)
if hasattr(msg, '__call__'):
msg = msg()
commitmsg = msg and msg or ("[mq]: %s" % patchfn)
@@ -1214,7 +1239,7 @@
cparents = repo.changelog.parents(top)
patchparent = self.qparents(repo, top)
- ph = patchheader(self.join(patchfn))
+ ph = patchheader(self.join(patchfn), self.plainmode)
diffopts = self.diffopts({'git': opts.get('git')}, patchfn)
if msg:
ph.setmessage(msg)
@@ -1222,6 +1247,7 @@
ph.setuser(newuser)
if newdate:
ph.setdate(newdate)
+ ph.setparent(hex(patchparent))
# only commit new patch when write is complete
patchf = self.opener(patchfn, 'w', atomictemp=True)
@@ -1406,7 +1432,7 @@
summary=False):
def displayname(pfx, patchname):
if summary:
- ph = patchheader(self.join(patchname))
+ ph = patchheader(self.join(patchname), self.plainmode)
msg = ph.message and ph.message[0] or ''
if self.ui.interactive():
width = util.termwidth() - len(pfx) - len(patchname) - 2
@@ -2012,7 +2038,7 @@
if message:
raise util.Abort(_('option "-e" incompatible with "-m" or "-l"'))
patch = q.applied[-1].name
- ph = patchheader(q.join(patch))
+ ph = patchheader(q.join(patch), q.plainmode)
message = ui.edit('\n'.join(ph.message), ph.user or ui.username())
setupheaderopts(ui, opts)
ret = q.refresh(repo, pats, msg=message, **opts)
@@ -2074,7 +2100,7 @@
for p in patches:
if not message:
- ph = patchheader(q.join(p))
+ ph = patchheader(q.join(p), q.plainmode)
if ph.message:
messages.append(ph.message)
pf = q.join(p)
@@ -2084,7 +2110,7 @@
patch.updatedir(ui, repo, files)
if not message:
- ph = patchheader(q.join(parent))
+ ph = patchheader(q.join(parent), q.plainmode)
message, user = ph.message, ph.user
for msg in messages:
message.append('* * *')
@@ -2167,7 +2193,7 @@
ui.write('no patches applied\n')
return 1
patch = q.lookup('qtip')
- ph = patchheader(repo.mq.join(patch))
+ ph = patchheader(q.join(patch), q.plainmode)
ui.write('\n'.join(ph.message) + '\n')
--- a/tests/test-mq Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq Sun Feb 07 10:47:54 2010 -0500
@@ -10,6 +10,9 @@
echo "[extensions]" >> $HGRCPATH
echo "mq=" >> $HGRCPATH
+echo "[mq]" >> $HGRCPATH
+echo "plain=true" >> $HGRCPATH
+
echo % help
hg help mq
--- a/tests/test-mq-git Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-git Sun Feb 07 10:47:54 2010 -0500
@@ -25,7 +25,7 @@
hg qnew -d '0 0' --git -f git
cat .hg/patches/git
echo '% git=auto: regular patch after qrefresh without --git'
-hg qrefresh -d '0 0'
+hg qrefresh -d '0 0'
cat .hg/patches/git
cd ..
--- a/tests/test-mq-git.out Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-git.out Sun Feb 07 10:47:54 2010 -0500
@@ -1,5 +1,6 @@
% git=auto: regular patch creation
# HG changeset patch
+# Parent 0000000000000000000000000000000000000000
# Date 0 0
diff -r 000000000000 -r ef8dafc9fa4c a
@@ -9,6 +10,7 @@
+a
% git=auto: git patch creation with copy
# HG changeset patch
+# Parent ef8dafc9fa4caff80f6e243eb0171bcd60c455b4
# Date 0 0
diff --git a/a b/b
@@ -16,6 +18,7 @@
copy to b
% git=auto: git patch when using --git
# HG changeset patch
+# Parent 2962f232b49d41ebc26c591ec8d556724be213ab
# Date 0 0
diff --git a/regular b/regular
@@ -26,6 +29,7 @@
+regular
% git=auto: regular patch after qrefresh without --git
# HG changeset patch
+# Parent 2962f232b49d41ebc26c591ec8d556724be213ab
# Date 0 0
diff -r 2962f232b49d regular
@@ -35,6 +39,7 @@
+regular
% git=keep: git patch with --git
# HG changeset patch
+# Parent 0000000000000000000000000000000000000000
# Date 0 0
diff --git a/a b/a
@@ -45,6 +50,7 @@
+a
% git=keep: git patch after qrefresh without --git
# HG changeset patch
+# Parent 0000000000000000000000000000000000000000
# Date 0 0
diff --git a/a b/a
@@ -56,6 +62,7 @@
+a
% git=yes: git patch
# HG changeset patch
+# Parent 0000000000000000000000000000000000000000
# Date 0 0
diff --git a/a b/a
@@ -66,6 +73,7 @@
+a
% git=yes: git patch after qrefresh
# HG changeset patch
+# Parent 0000000000000000000000000000000000000000
# Date 0 0
diff --git a/a b/a
@@ -77,6 +85,7 @@
+a
% git=no: regular patch with copy
# HG changeset patch
+# Parent ef8dafc9fa4caff80f6e243eb0171bcd60c455b4
# Date 0 0
diff -r ef8dafc9fa4c -r 110cde11d262 b
@@ -86,6 +95,7 @@
+a
% git=no: regular patch after qrefresh with copy
# HG changeset patch
+# Parent ef8dafc9fa4caff80f6e243eb0171bcd60c455b4
# Date 0 0
diff -r ef8dafc9fa4c b
--- a/tests/test-mq-header-date Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-header-date Sun Feb 07 10:47:54 2010 -0500
@@ -7,7 +7,8 @@
catpatch() {
- cat .hg/patches/$1.patch | sed -e "s/^diff \-r [0-9a-f]* /diff -r ... /"
+ cat .hg/patches/$1.patch | sed -e "s/^diff \-r [0-9a-f]* /diff -r ... /" \
+ -e "s/^\(# Parent \).*/\1/"
}
catlog() {
@@ -25,153 +26,192 @@
hg qdel $1.patch
}
-
-echo ==== init
-hg init a
-cd a
-hg qinit
+runtest() {
+ echo ==== init
+ hg init a
+ cd a
+ hg qinit
-echo ==== qnew -d
-hg qnew -d '3 0' 1.patch
-catlogd 1
+ echo ==== qnew -d
+ hg qnew -d '3 0' 1.patch
+ catlogd 1
-echo ==== qref
-echo "1" >1
-hg add
-hg qref
-catlogd 1
+ echo ==== qref
+ echo "1" >1
+ hg add
+ hg qref
+ catlogd 1
-echo ==== qref -d
-hg qref -d '4 0'
-catlogd 1
+ echo ==== qref -d
+ hg qref -d '4 0'
+ catlogd 1
-echo ==== qnew
-hg qnew 2.patch
-echo "2" >2
-hg add
-hg qref
-catlog 2
+ echo ==== qnew
+ hg qnew 2.patch
+ echo "2" >2
+ hg add
+ hg qref
+ catlog 2
-echo ==== qref -d
-hg qref -d '5 0'
-catlog 2
+ echo ==== qref -d
+ hg qref -d '5 0'
+ catlog 2
-drop 2
+ drop 2
-echo ==== qnew -d -m
-hg qnew -d '6 0' -m "Three" 3.patch
-catlogd 3
+ echo ==== qnew -d -m
+ hg qnew -d '6 0' -m "Three" 3.patch
+ catlogd 3
-echo ==== qref
-echo "3" >3
-hg add
-hg qref
-catlogd 3
+ echo ==== qref
+ echo "3" >3
+ hg add
+ hg qref
+ catlogd 3
-echo ==== qref -m
-hg qref -m "Drei"
-catlogd 3
+ echo ==== qref -m
+ hg qref -m "Drei"
+ catlogd 3
-echo ==== qref -d
-hg qref -d '7 0'
-catlogd 3
+ echo ==== qref -d
+ hg qref -d '7 0'
+ catlogd 3
-echo ==== qref -d -m
-hg qref -d '8 0' -m "Three (again)"
-catlogd 3
+ echo ==== qref -d -m
+ hg qref -d '8 0' -m "Three (again)"
+ catlogd 3
-echo ==== qnew -m
-hg qnew -m "Four" 4.patch
-echo "4" >4
-hg add
-hg qref
-catlog 4
+ echo ==== qnew -m
+ hg qnew -m "Four" 4.patch
+ echo "4" >4
+ hg add
+ hg qref
+ catlog 4
+
+ echo ==== qref -d
+ hg qref -d '9 0'
+ catlog 4
+
+ drop 4
+
-echo ==== qref -d
-hg qref -d '9 0'
-catlog 4
+ echo ==== qnew with HG header
+ hg qnew --config 'mq.plain=true' 5.patch
+ hg qpop
+ echo "# HG changeset patch" >>.hg/patches/5.patch
+ echo "# Date 10 0" >>.hg/patches/5.patch
+ hg qpush 2>&1 | grep 'Now at'
+ catlogd 5
-drop 4
+ echo ==== hg qref
+ echo "5" >5
+ hg add
+ hg qref
+ catlogd 5
+
+ echo ==== hg qref -d
+ hg qref -d '11 0'
+ catlogd 5
-echo ==== qnew with HG header
-hg qnew 5.patch
-hg qpop
-echo "# HG changeset patch" >>.hg/patches/5.patch
-echo "# Date 10 0" >>.hg/patches/5.patch
-hg qpush 2>&1 | grep 'Now at'
-catlogd 5
+ echo ==== qnew with plain header
+ hg qnew --config 'mq.plain=true' -d '12 0' 6.patch
+ hg qpop
+ hg qpush 2>&1 | grep 'now at'
+ catlog 6
+
+ echo ==== hg qref
+ echo "6" >6
+ hg add
+ hg qref
+ catlogd 6
+
+ echo ==== hg qref -d
+ hg qref -d '13 0'
+ catlogd 6
-echo ==== hg qref
-echo "5" >5
-hg add
-hg qref
-catlogd 5
+ drop 6
+
-echo ==== hg qref -d
-hg qref -d '11 0'
-catlogd 5
+ echo ==== qnew -u
+ hg qnew -u jane 6.patch
+ echo "6" >6
+ hg add
+ hg qref
+ catlog 6
+
+ echo ==== qref -d
+ hg qref -d '12 0'
+ catlog 6
+
+ drop 6
-echo ==== qnew -u
-hg qnew -u jane 6.patch
-echo "6" >6
-hg add
-hg qref
-catlog 6
+ echo ==== qnew -d
+ hg qnew -d '13 0' 7.patch
+ echo "7" >7
+ hg add
+ hg qref
+ catlog 7
-echo ==== qref -d
-hg qref -d '12 0'
-catlog 6
-
-drop 6
+ echo ==== qref -u
+ hg qref -u john
+ catlogd 7
-echo ==== qnew -d
-hg qnew -d '13 0' 7.patch
-echo "7" >7
-hg add
-hg qref
-catlog 7
+ echo ==== qnew
+ hg qnew 8.patch
+ echo "8" >8
+ hg add
+ hg qref
+ catlog 8
-echo ==== qref -u
-hg qref -u john
-catlogd 7
+ echo ==== qref -u -d
+ hg qref -u john -d '14 0'
+ catlog 8
+
+ drop 8
-echo ==== qnew
-hg qnew 8.patch
-echo "8" >8
-hg add
-hg qref
-catlog 8
+ echo ==== qnew -m
+ hg qnew -m "Nine" 9.patch
+ echo "9" >9
+ hg add
+ hg qref
+ catlog 9
-echo ==== qref -u -d
-hg qref -u john -d '14 0'
-catlog 8
+ echo ==== qref -u -d
+ hg qref -u john -d '15 0'
+ catlog 9
-drop 8
+ drop 9
-echo ==== qnew -m
-hg qnew -m "Nine" 9.patch
-echo "9" >9
-hg add
-hg qref
-catlog 9
-
-echo ==== qref -u -d
-hg qref -u john -d '15 0'
-catlog 9
-
-drop 9
+ echo ==== "qpop -a / qpush -a"
+ hg qpop -a
+ hg qpush -a
+ hg log --template "{rev}: {desc} - {author} - {date}\n"
+}
-echo ==== "qpop -a / qpush -a"
-hg qpop -a
-hg qpush -a
-hg log --template "{rev}: {desc} - {author} - {date}\n"
+echo ======= plain headers
+
+echo "[mq]" >> $HGRCPATH
+echo "plain=true" >> $HGRCPATH
+
+mkdir sandbox
+(cd sandbox ; runtest)
+rm -r sandbox
+
+
+echo ======= hg headers
+
+echo "plain=false" >> $HGRCPATH
+
+mkdir sandbox
+(cd sandbox ; runtest)
+rm -r sandbox
--- a/tests/test-mq-header-date.out Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-header-date.out Sun Feb 07 10:47:54 2010 -0500
@@ -1,13 +1,12 @@
+======= plain headers
==== init
==== qnew -d
-# HG changeset patch
-# Date 3 0
+Date: 3 0
0: [mq]: 1.patch - test - 3.00
==== qref
adding 1
-# HG changeset patch
-# Date 3 0
+Date: 3 0
diff -r ... 1
--- /dev/null
@@ -16,8 +15,7 @@
+1
0: [mq]: 1.patch - test - 3.00
==== qref -d
-# HG changeset patch
-# Date 4 0
+Date: 4 0
diff -r ... 1
--- /dev/null
@@ -35,9 +33,7 @@
1: [mq]: 2.patch - test
0: [mq]: 1.patch - test
==== qref -d
-# HG changeset patch
-# Date 5 0
-
+Date: 5 0
diff -r ... 2
--- /dev/null
@@ -49,8 +45,7 @@
popping 2.patch
now at: 1.patch
==== qnew -d -m
-# HG changeset patch
-# Date 6 0
+Date: 6 0
Three
@@ -58,8 +53,7 @@
0: [mq]: 1.patch - test - 4.00
==== qref
adding 3
-# HG changeset patch
-# Date 6 0
+Date: 6 0
Three
@@ -71,8 +65,7 @@
1: Three - test - 6.00
0: [mq]: 1.patch - test - 4.00
==== qref -m
-# HG changeset patch
-# Date 6 0
+Date: 6 0
Drei
@@ -84,8 +77,7 @@
1: Drei - test - 6.00
0: [mq]: 1.patch - test - 4.00
==== qref -d
-# HG changeset patch
-# Date 7 0
+Date: 7 0
Drei
@@ -97,8 +89,7 @@
1: Drei - test - 7.00
0: [mq]: 1.patch - test - 4.00
==== qref -d -m
-# HG changeset patch
-# Date 8 0
+Date: 8 0
Three (again)
@@ -122,9 +113,7 @@
1: Three (again) - test
0: [mq]: 1.patch - test
==== qref -d
-# HG changeset patch
-# Date 9 0
-
+Date: 9 0
Four
diff -r ... 4
@@ -148,6 +137,7 @@
==== hg qref
adding 5
# HG changeset patch
+# Parent
# Date 10 0
diff -r ... 5
@@ -160,6 +150,7 @@
0: [mq]: 1.patch - test - 4.00
==== hg qref -d
# HG changeset patch
+# Parent
# Date 11 0
diff -r ... 5
@@ -170,6 +161,43 @@
2: [mq]: 5.patch - test - 11.00
1: Three (again) - test - 8.00
0: [mq]: 1.patch - test - 4.00
+==== qnew with plain header
+popping 6.patch
+now at: 5.patch
+now at: 6.patch
+Date: 12 0
+
+3: imported patch 6.patch - test
+2: [mq]: 5.patch - test
+1: Three (again) - test
+0: [mq]: 1.patch - test
+==== hg qref
+adding 6
+Date: 12 0
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+3: [mq]: 6.patch - test - 12.00
+2: [mq]: 5.patch - test - 11.00
+1: Three (again) - test - 8.00
+0: [mq]: 1.patch - test - 4.00
+==== hg qref -d
+Date: 13 0
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+3: [mq]: 6.patch - test - 13.00
+2: [mq]: 5.patch - test - 11.00
+1: Three (again) - test - 8.00
+0: [mq]: 1.patch - test - 4.00
+popping 6.patch
+now at: 5.patch
==== qnew -u
adding 6
From: jane
@@ -200,8 +228,7 @@
now at: 5.patch
==== qnew -d
adding 7
-# HG changeset patch
-# Date 13 0
+Date: 13 0
diff -r ... 7
--- /dev/null
@@ -213,9 +240,8 @@
1: Three (again) - test
0: [mq]: 1.patch - test
==== qref -u
-# HG changeset patch
-# User john
-# Date 13 0
+From: john
+Date: 13 0
diff -r ... 7
--- /dev/null
@@ -239,10 +265,8 @@
1: Three (again) - test
0: [mq]: 1.patch - test
==== qref -u -d
-# HG changeset patch
-# Date 14 0
-# User john
-
+Date: 14 0
+From: john
diff -r ... 8
--- /dev/null
@@ -271,10 +295,8 @@
1: Three (again) - test
0: [mq]: 1.patch - test
==== qref -u -d
-# HG changeset patch
-# Date 15 0
-# User john
-
+Date: 15 0
+From: john
Nine
diff -r ... 9
@@ -304,3 +326,373 @@
2: imported patch 5.patch - test - 11.00
1: Three (again) - test - 8.00
0: imported patch 1.patch - test - 4.00
+======= hg headers
+==== init
+==== qnew -d
+# HG changeset patch
+# Parent
+# Date 3 0
+
+0: [mq]: 1.patch - test - 3.00
+==== qref
+adding 1
+# HG changeset patch
+# Parent
+# Date 3 0
+
+diff -r ... 1
+--- /dev/null
++++ b/1
+@@ -0,0 +1,1 @@
++1
+0: [mq]: 1.patch - test - 3.00
+==== qref -d
+# HG changeset patch
+# Parent
+# Date 4 0
+
+diff -r ... 1
+--- /dev/null
++++ b/1
+@@ -0,0 +1,1 @@
++1
+0: [mq]: 1.patch - test - 4.00
+==== qnew
+adding 2
+# HG changeset patch
+# Parent
+
+diff -r ... 2
+--- /dev/null
++++ b/2
+@@ -0,0 +1,1 @@
++2
+1: [mq]: 2.patch - test
+0: [mq]: 1.patch - test
+==== qref -d
+# HG changeset patch
+# Date 5 0
+# Parent
+
+diff -r ... 2
+--- /dev/null
++++ b/2
+@@ -0,0 +1,1 @@
++2
+1: [mq]: 2.patch - test
+0: [mq]: 1.patch - test
+popping 2.patch
+now at: 1.patch
+==== qnew -d -m
+# HG changeset patch
+# Parent
+# Date 6 0
+
+Three
+
+1: Three - test - 6.00
+0: [mq]: 1.patch - test - 4.00
+==== qref
+adding 3
+# HG changeset patch
+# Parent
+# Date 6 0
+
+Three
+
+diff -r ... 3
+--- /dev/null
++++ b/3
+@@ -0,0 +1,1 @@
++3
+1: Three - test - 6.00
+0: [mq]: 1.patch - test - 4.00
+==== qref -m
+# HG changeset patch
+# Parent
+# Date 6 0
+
+Drei
+
+diff -r ... 3
+--- /dev/null
++++ b/3
+@@ -0,0 +1,1 @@
++3
+1: Drei - test - 6.00
+0: [mq]: 1.patch - test - 4.00
+==== qref -d
+# HG changeset patch
+# Parent
+# Date 7 0
+
+Drei
+
+diff -r ... 3
+--- /dev/null
++++ b/3
+@@ -0,0 +1,1 @@
++3
+1: Drei - test - 7.00
+0: [mq]: 1.patch - test - 4.00
+==== qref -d -m
+# HG changeset patch
+# Parent
+# Date 8 0
+
+Three (again)
+
+diff -r ... 3
+--- /dev/null
++++ b/3
+@@ -0,0 +1,1 @@
++3
+1: Three (again) - test - 8.00
+0: [mq]: 1.patch - test - 4.00
+==== qnew -m
+adding 4
+# HG changeset patch
+# Parent
+Four
+
+diff -r ... 4
+--- /dev/null
++++ b/4
+@@ -0,0 +1,1 @@
++4
+2: Four - test
+1: Three (again) - test
+0: [mq]: 1.patch - test
+==== qref -d
+# HG changeset patch
+# Date 9 0
+# Parent
+Four
+
+diff -r ... 4
+--- /dev/null
++++ b/4
+@@ -0,0 +1,1 @@
++4
+2: Four - test
+1: Three (again) - test
+0: [mq]: 1.patch - test
+popping 4.patch
+now at: 3.patch
+==== qnew with HG header
+popping 5.patch
+now at: 3.patch
+# HG changeset patch
+# Date 10 0
+2: imported patch 5.patch - test - 10.00
+1: Three (again) - test - 8.00
+0: [mq]: 1.patch - test - 4.00
+==== hg qref
+adding 5
+# HG changeset patch
+# Parent
+# Date 10 0
+
+diff -r ... 5
+--- /dev/null
++++ b/5
+@@ -0,0 +1,1 @@
++5
+2: [mq]: 5.patch - test - 10.00
+1: Three (again) - test - 8.00
+0: [mq]: 1.patch - test - 4.00
+==== hg qref -d
+# HG changeset patch
+# Parent
+# Date 11 0
+
+diff -r ... 5
+--- /dev/null
++++ b/5
+@@ -0,0 +1,1 @@
++5
+2: [mq]: 5.patch - test - 11.00
+1: Three (again) - test - 8.00
+0: [mq]: 1.patch - test - 4.00
+==== qnew with plain header
+popping 6.patch
+now at: 5.patch
+now at: 6.patch
+Date: 12 0
+
+3: imported patch 6.patch - test
+2: [mq]: 5.patch - test
+1: Three (again) - test
+0: [mq]: 1.patch - test
+==== hg qref
+adding 6
+Date: 12 0
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+3: [mq]: 6.patch - test - 12.00
+2: [mq]: 5.patch - test - 11.00
+1: Three (again) - test - 8.00
+0: [mq]: 1.patch - test - 4.00
+==== hg qref -d
+Date: 13 0
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+3: [mq]: 6.patch - test - 13.00
+2: [mq]: 5.patch - test - 11.00
+1: Three (again) - test - 8.00
+0: [mq]: 1.patch - test - 4.00
+popping 6.patch
+now at: 5.patch
+==== qnew -u
+adding 6
+# HG changeset patch
+# Parent
+# User jane
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+3: [mq]: 6.patch - jane
+2: [mq]: 5.patch - test
+1: Three (again) - test
+0: [mq]: 1.patch - test
+==== qref -d
+# HG changeset patch
+# Date 12 0
+# Parent
+# User jane
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+3: [mq]: 6.patch - jane
+2: [mq]: 5.patch - test
+1: Three (again) - test
+0: [mq]: 1.patch - test
+popping 6.patch
+now at: 5.patch
+==== qnew -d
+adding 7
+# HG changeset patch
+# Parent
+# Date 13 0
+
+diff -r ... 7
+--- /dev/null
++++ b/7
+@@ -0,0 +1,1 @@
++7
+3: [mq]: 7.patch - test
+2: [mq]: 5.patch - test
+1: Three (again) - test
+0: [mq]: 1.patch - test
+==== qref -u
+# HG changeset patch
+# User john
+# Parent
+# Date 13 0
+
+diff -r ... 7
+--- /dev/null
++++ b/7
+@@ -0,0 +1,1 @@
++7
+3: [mq]: 7.patch - john - 13.00
+2: [mq]: 5.patch - test - 11.00
+1: Three (again) - test - 8.00
+0: [mq]: 1.patch - test - 4.00
+==== qnew
+adding 8
+# HG changeset patch
+# Parent
+
+diff -r ... 8
+--- /dev/null
++++ b/8
+@@ -0,0 +1,1 @@
++8
+4: [mq]: 8.patch - test
+3: [mq]: 7.patch - john
+2: [mq]: 5.patch - test
+1: Three (again) - test
+0: [mq]: 1.patch - test
+==== qref -u -d
+# HG changeset patch
+# Date 14 0
+# User john
+# Parent
+
+diff -r ... 8
+--- /dev/null
++++ b/8
+@@ -0,0 +1,1 @@
++8
+4: [mq]: 8.patch - john
+3: [mq]: 7.patch - john
+2: [mq]: 5.patch - test
+1: Three (again) - test
+0: [mq]: 1.patch - test
+popping 8.patch
+now at: 7.patch
+==== qnew -m
+adding 9
+# HG changeset patch
+# Parent
+Nine
+
+diff -r ... 9
+--- /dev/null
++++ b/9
+@@ -0,0 +1,1 @@
++9
+4: Nine - test
+3: [mq]: 7.patch - john
+2: [mq]: 5.patch - test
+1: Three (again) - test
+0: [mq]: 1.patch - test
+==== qref -u -d
+# HG changeset patch
+# Date 15 0
+# User john
+# Parent
+Nine
+
+diff -r ... 9
+--- /dev/null
++++ b/9
+@@ -0,0 +1,1 @@
++9
+4: Nine - john
+3: [mq]: 7.patch - john
+2: [mq]: 5.patch - test
+1: Three (again) - test
+0: [mq]: 1.patch - test
+popping 9.patch
+now at: 7.patch
+==== qpop -a / qpush -a
+popping 7.patch
+popping 5.patch
+popping 3.patch
+popping 1.patch
+patch queue now empty
+applying 1.patch
+applying 3.patch
+applying 5.patch
+applying 7.patch
+now at: 7.patch
+3: imported patch 7.patch - john - 13.00
+2: imported patch 5.patch - test - 11.00
+1: Three (again) - test - 8.00
+0: imported patch 1.patch - test - 4.00
--- a/tests/test-mq-header-from Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-header-from Sun Feb 07 10:47:54 2010 -0500
@@ -7,101 +7,145 @@
catlog() {
- cat .hg/patches/$1.patch | sed -e "s/^diff \-r [0-9a-f]* /diff -r ... /"
+ cat .hg/patches/$1.patch | sed -e "s/^diff \-r [0-9a-f]* /diff -r ... /" \
+ -e "s/^\(# Parent \).*/\1/"
+ hg log --template "{rev}: {desc} - {author}\n"
+}
+
+runtest() {
+ echo ==== init
+ hg init a
+ cd a
+ hg qinit
+
+
+ echo ==== qnew -U
+ hg qnew -U 1.patch
+ catlog 1
+
+ echo ==== qref
+ echo "1" >1
+ hg add
+ hg qref
+ catlog 1
+
+ echo ==== qref -u
+ hg qref -u mary
+ catlog 1
+
+ echo ==== qnew
+ hg qnew 2.patch
+ echo "2" >2
+ hg add
+ hg qref
+ catlog 2
+
+ echo ==== qref -u
+ hg qref -u jane
+ catlog 2
+
+
+ echo ==== qnew -U -m
+ hg qnew -U -m "Three" 3.patch
+ catlog 3
+
+ echo ==== qref
+ echo "3" >3
+ hg add
+ hg qref
+ catlog 3
+
+ echo ==== qref -m
+ hg qref -m "Drei"
+ catlog 3
+
+ echo ==== qref -u
+ hg qref -u mary
+ catlog 3
+
+ echo ==== qref -u -m
+ hg qref -u maria -m "Three (again)"
+ catlog 3
+
+ echo ==== qnew -m
+ hg qnew -m "Four" 4.patch
+ echo "4" >4of t
+ hg add
+ hg qref
+ catlog 4
+
+ echo ==== qref -u
+ hg qref -u jane
+ catlog 4
+
+
+ echo ==== qnew with HG header
+ hg qnew --config 'mq.plain=true' 5.patch
+ hg qpop
+ echo "# HG changeset patch" >>.hg/patches/5.patch
+ echo "# User johndoe" >>.hg/patches/5.patch
+ hg qpush 2>&1 | grep 'now at'
+ catlog 5
+
+ echo ==== hg qref
+ echo "5" >5
+ hg add
+ hg qref
+ catlog 5
+
+ echo ==== hg qref -U
+ hg qref -U
+ catlog 5
+
+ echo ==== hg qref -u
+ hg qref -u johndeere
+ catlog 5
+
+
+ echo ==== qnew with plain header
+ hg qnew --config 'mq.plain=true' -U 6.patch
+ hg qpop
+ hg qpush 2>&1 | grep 'now at'
+ catlog 6
+
+ echo ==== hg qref
+ echo "6" >6
+ hg add
+ hg qref
+ catlog 6
+
+ echo ==== hg qref -U
+ hg qref -U
+ catlog 6
+
+ echo ==== hg qref -u
+ hg qref -u johndeere
+ catlog 6
+
+
+ echo ==== "qpop -a / qpush -a"
+ hg qpop -a
+ hg qpush -a
hg log --template "{rev}: {desc} - {author}\n"
}
-echo ==== init
-hg init a
-cd a
-hg qinit
-
-
-echo ==== qnew -U
-hg qnew -U 1.patch
-catlog 1
+echo ======= plain headers
-echo ==== qref
-echo "1" >1
-hg add
-hg qref
-catlog 1
-
-echo ==== qref -u
-hg qref -u mary
-catlog 1
+echo "[mq]" >> $HGRCPATH
+echo "plain=true" >> $HGRCPATH
-echo ==== qnew
-hg qnew 2.patch
-echo "2" >2
-hg add
-hg qref
-catlog 2
-
-echo ==== qref -u
-hg qref -u jane
-catlog 2
+mkdir sandbox
+(cd sandbox ; runtest)
+rm -r sandbox
-echo ==== qnew -U -m
-hg qnew -U -m "Three" 3.patch
-catlog 3
-
-echo ==== qref
-echo "3" >3
-hg add
-hg qref
-catlog 3
-
-echo ==== qref -m
-hg qref -m "Drei"
-catlog 3
+echo ======= hg headers
-echo ==== qref -u
-hg qref -u mary
-catlog 3
-
-echo ==== qref -u -m
-hg qref -u maria -m "Three (again)"
-catlog 3
-
-echo ==== qnew -m
-hg qnew -m "Four" 4.patch
-echo "4" >4
-hg add
-hg qref
-catlog 4
+echo "plain=false" >> $HGRCPATH
-echo ==== qref -u
-hg qref -u jane
-catlog 4
-
-
-echo ==== qnew with HG header
-hg qnew 5.patch
-hg qpop
-echo "# HG changeset patch" >>.hg/patches/5.patch
-echo "# User johndoe" >>.hg/patches/5.patch
-hg qpush 2>&1 | grep 'now at'
-catlog 5
+mkdir sandbox
+(cd sandbox ; runtest)
+rm -r sandbox
-echo ==== hg qref
-echo "5" >5
-hg add
-hg qref
-catlog 5
-
-echo ==== hg qref -U
-hg qref -U
-catlog 5
-
-echo ==== hg qref -u
-hg qref -u johndeere
-catlog 5
-
-
-echo ==== "qpop -a / qpush -a"
-hg qpop -a
-hg qpush -a
-hg log --template "{rev}: {desc} - {author}\n"
+runtest
\ No newline at end of file
--- a/tests/test-mq-header-from.out Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-header-from.out Sun Feb 07 10:47:54 2010 -0500
@@ -1,3 +1,4 @@
+======= plain headers
==== init
==== qnew -U
From: test
@@ -32,9 +33,7 @@
1: [mq]: 2.patch - test
0: [mq]: 1.patch - mary
==== qref -u
-# HG changeset patch
-# User jane
-
+From: jane
diff -r ... 2
--- /dev/null
@@ -105,14 +104,295 @@
1: [mq]: 2.patch - jane
0: [mq]: 1.patch - mary
==== qnew -m
-adding 4
+adding 4of
+Four
+
+diff -r ... 4of
+--- /dev/null
++++ b/4of
+@@ -0,0 +1,1 @@
++4 t
+3: Four - test
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qref -u
+From: jane
Four
-diff -r ... 4
+diff -r ... 4of
+--- /dev/null
++++ b/4of
+@@ -0,0 +1,1 @@
++4 t
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qnew with HG header
+popping 5.patch
+now at: 4.patch
+now at: 5.patch
+# HG changeset patch
+# User johndoe
+4: imported patch 5.patch - johndoe
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref
+adding 5
+# HG changeset patch
+# Parent
+# User johndoe
+
+diff -r ... 5
+--- /dev/null
++++ b/5
+@@ -0,0 +1,1 @@
++5
+4: [mq]: 5.patch - johndoe
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref -U
+# HG changeset patch
+# Parent
+# User test
+
+diff -r ... 5
+--- /dev/null
++++ b/5
+@@ -0,0 +1,1 @@
++5
+4: [mq]: 5.patch - test
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref -u
+# HG changeset patch
+# Parent
+# User johndeere
+
+diff -r ... 5
+--- /dev/null
++++ b/5
+@@ -0,0 +1,1 @@
++5
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qnew with plain header
+popping 6.patch
+now at: 5.patch
+now at: 6.patch
+From: test
+
+5: imported patch 6.patch - test
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref
+adding 6
+From: test
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+5: [mq]: 6.patch - test
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref -U
+From: test
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+5: [mq]: 6.patch - test
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref -u
+From: johndeere
+
+diff -r ... 6
--- /dev/null
-+++ b/4
++++ b/6
+@@ -0,0 +1,1 @@
++6
+5: [mq]: 6.patch - johndeere
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qpop -a / qpush -a
+popping 6.patch
+popping 5.patch
+popping 4.patch
+popping 3.patch
+popping 2.patch
+popping 1.patch
+patch queue now empty
+applying 1.patch
+applying 2.patch
+applying 3.patch
+applying 4.patch
+applying 5.patch
+applying 6.patch
+now at: 6.patch
+5: imported patch 6.patch - johndeere
+4: imported patch 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: imported patch 2.patch - jane
+0: imported patch 1.patch - mary
+======= hg headers
+==== init
+==== qnew -U
+# HG changeset patch
+# Parent
+# User test
+0: [mq]: 1.patch - test
+==== qref
+adding 1
+# HG changeset patch
+# Parent
+# User test
+
+diff -r ... 1
+--- /dev/null
++++ b/1
+@@ -0,0 +1,1 @@
++1
+0: [mq]: 1.patch - test
+==== qref -u
+# HG changeset patch
+# Parent
+# User mary
+
+diff -r ... 1
+--- /dev/null
++++ b/1
+@@ -0,0 +1,1 @@
++1
+0: [mq]: 1.patch - mary
+==== qnew
+adding 2
+# HG changeset patch
+# Parent
+
+diff -r ... 2
+--- /dev/null
++++ b/2
+@@ -0,0 +1,1 @@
++2
+1: [mq]: 2.patch - test
+0: [mq]: 1.patch - mary
+==== qref -u
+# HG changeset patch
+# User jane
+# Parent
+
+diff -r ... 2
+--- /dev/null
++++ b/2
@@ -0,0 +1,1 @@
-+4
++2
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qnew -U -m
+# HG changeset patch
+# Parent
+# User test
+Three
+
+2: Three - test
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qref
+adding 3
+# HG changeset patch
+# Parent
+# User test
+Three
+
+diff -r ... 3
+--- /dev/null
++++ b/3
+@@ -0,0 +1,1 @@
++3
+2: Three - test
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qref -m
+# HG changeset patch
+# Parent
+# User test
+Drei
+
+diff -r ... 3
+--- /dev/null
++++ b/3
+@@ -0,0 +1,1 @@
++3
+2: Drei - test
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qref -u
+# HG changeset patch
+# Parent
+# User mary
+Drei
+
+diff -r ... 3
+--- /dev/null
++++ b/3
+@@ -0,0 +1,1 @@
++3
+2: Drei - mary
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qref -u -m
+# HG changeset patch
+# Parent
+# User maria
+Three (again)
+
+diff -r ... 3
+--- /dev/null
++++ b/3
+@@ -0,0 +1,1 @@
++3
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qnew -m
+adding 4of
+# HG changeset patch
+# Parent
+Four
+
+diff -r ... 4of
+--- /dev/null
++++ b/4of
+@@ -0,0 +1,1 @@
++4 t
3: Four - test
2: Three (again) - maria
1: [mq]: 2.patch - jane
@@ -120,14 +400,14 @@
==== qref -u
# HG changeset patch
# User jane
-
+# Parent
Four
-diff -r ... 4
+diff -r ... 4of
--- /dev/null
-+++ b/4
++++ b/4of
@@ -0,0 +1,1 @@
-+4
++4 t
3: Four - jane
2: Three (again) - maria
1: [mq]: 2.patch - jane
@@ -146,6 +426,7 @@
==== hg qref
adding 5
# HG changeset patch
+# Parent
# User johndoe
diff -r ... 5
@@ -160,6 +441,7 @@
0: [mq]: 1.patch - mary
==== hg qref -U
# HG changeset patch
+# Parent
# User test
diff -r ... 5
@@ -174,6 +456,7 @@
0: [mq]: 1.patch - mary
==== hg qref -u
# HG changeset patch
+# Parent
# User johndeere
diff -r ... 5
@@ -186,7 +469,63 @@
2: Three (again) - maria
1: [mq]: 2.patch - jane
0: [mq]: 1.patch - mary
+==== qnew with plain header
+popping 6.patch
+now at: 5.patch
+now at: 6.patch
+From: test
+
+5: imported patch 6.patch - test
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref
+adding 6
+From: test
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+5: [mq]: 6.patch - test
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref -U
+From: test
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+5: [mq]: 6.patch - test
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref -u
+From: johndeere
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+5: [mq]: 6.patch - johndeere
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
==== qpop -a / qpush -a
+popping 6.patch
popping 5.patch
popping 4.patch
popping 3.patch
@@ -198,9 +537,293 @@
applying 3.patch
applying 4.patch
applying 5.patch
-now at: 5.patch
+applying 6.patch
+now at: 6.patch
+5: imported patch 6.patch - johndeere
4: imported patch 5.patch - johndeere
3: Four - jane
2: Three (again) - maria
1: imported patch 2.patch - jane
0: imported patch 1.patch - mary
+==== init
+==== qnew -U
+# HG changeset patch
+# Parent
+# User test
+0: [mq]: 1.patch - test
+==== qref
+adding 1
+# HG changeset patch
+# Parent
+# User test
+
+diff -r ... 1
+--- /dev/null
++++ b/1
+@@ -0,0 +1,1 @@
++1
+0: [mq]: 1.patch - test
+==== qref -u
+# HG changeset patch
+# Parent
+# User mary
+
+diff -r ... 1
+--- /dev/null
++++ b/1
+@@ -0,0 +1,1 @@
++1
+0: [mq]: 1.patch - mary
+==== qnew
+adding 2
+# HG changeset patch
+# Parent
+
+diff -r ... 2
+--- /dev/null
++++ b/2
+@@ -0,0 +1,1 @@
++2
+1: [mq]: 2.patch - test
+0: [mq]: 1.patch - mary
+==== qref -u
+# HG changeset patch
+# User jane
+# Parent
+
+diff -r ... 2
+--- /dev/null
++++ b/2
+@@ -0,0 +1,1 @@
++2
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qnew -U -m
+# HG changeset patch
+# Parent
+# User test
+Three
+
+2: Three - test
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qref
+adding 3
+# HG changeset patch
+# Parent
+# User test
+Three
+
+diff -r ... 3
+--- /dev/null
++++ b/3
+@@ -0,0 +1,1 @@
++3
+2: Three - test
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qref -m
+# HG changeset patch
+# Parent
+# User test
+Drei
+
+diff -r ... 3
+--- /dev/null
++++ b/3
+@@ -0,0 +1,1 @@
++3
+2: Drei - test
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qref -u
+# HG changeset patch
+# Parent
+# User mary
+Drei
+
+diff -r ... 3
+--- /dev/null
++++ b/3
+@@ -0,0 +1,1 @@
++3
+2: Drei - mary
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qref -u -m
+# HG changeset patch
+# Parent
+# User maria
+Three (again)
+
+diff -r ... 3
+--- /dev/null
++++ b/3
+@@ -0,0 +1,1 @@
++3
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qnew -m
+adding 4of
+# HG changeset patch
+# Parent
+Four
+
+diff -r ... 4of
+--- /dev/null
++++ b/4of
+@@ -0,0 +1,1 @@
++4 t
+3: Four - test
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qref -u
+# HG changeset patch
+# User jane
+# Parent
+Four
+
+diff -r ... 4of
+--- /dev/null
++++ b/4of
+@@ -0,0 +1,1 @@
++4 t
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qnew with HG header
+popping 5.patch
+now at: 4.patch
+now at: 5.patch
+# HG changeset patch
+# User johndoe
+4: imported patch 5.patch - johndoe
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref
+adding 5
+# HG changeset patch
+# Parent
+# User johndoe
+
+diff -r ... 5
+--- /dev/null
++++ b/5
+@@ -0,0 +1,1 @@
++5
+4: [mq]: 5.patch - johndoe
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref -U
+# HG changeset patch
+# Parent
+# User test
+
+diff -r ... 5
+--- /dev/null
++++ b/5
+@@ -0,0 +1,1 @@
++5
+4: [mq]: 5.patch - test
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref -u
+# HG changeset patch
+# Parent
+# User johndeere
+
+diff -r ... 5
+--- /dev/null
++++ b/5
+@@ -0,0 +1,1 @@
++5
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qnew with plain header
+popping 6.patch
+now at: 5.patch
+now at: 6.patch
+From: test
+
+5: imported patch 6.patch - test
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref
+adding 6
+From: test
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+5: [mq]: 6.patch - test
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref -U
+From: test
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+5: [mq]: 6.patch - test
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== hg qref -u
+From: johndeere
+
+diff -r ... 6
+--- /dev/null
++++ b/6
+@@ -0,0 +1,1 @@
++6
+5: [mq]: 6.patch - johndeere
+4: [mq]: 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: [mq]: 2.patch - jane
+0: [mq]: 1.patch - mary
+==== qpop -a / qpush -a
+popping 6.patch
+popping 5.patch
+popping 4.patch
+popping 3.patch
+popping 2.patch
+popping 1.patch
+patch queue now empty
+applying 1.patch
+applying 2.patch
+applying 3.patch
+applying 4.patch
+applying 5.patch
+applying 6.patch
+now at: 6.patch
+5: imported patch 6.patch - johndeere
+4: imported patch 5.patch - johndeere
+3: Four - jane
+2: Three (again) - maria
+1: imported patch 2.patch - jane
+0: imported patch 1.patch - mary
--- a/tests/test-mq-merge.out Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-merge.out Sun Feb 07 10:47:54 2010 -0500
@@ -34,6 +34,9 @@
applying patcha2
now at: patcha2
% check patcha is still a git patch
+# HG changeset patch
+# Parent d3873e73d99ef67873dac33fbcc66268d5d2b6f4
+
diff --git a/a b/a
--- a/a
+++ b/a
--- a/tests/test-mq-qfold Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-qfold Sun Feb 07 10:47:54 2010 -0500
@@ -12,6 +12,11 @@
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
}
+filterpatch()
+{
+ sed -e "s/\(# Parent \).*/\1/"
+}
+
echo '% init'
hg init repo
cd repo
@@ -43,7 +48,7 @@
hg qnew --git -f git
hg qpop
hg qfold git
-cat .hg/patches/regular
+cat .hg/patches/regular | filterpatch
hg qpop
hg qdel regular
@@ -54,7 +59,7 @@
hg qnew -f regular
hg qpop
hg qfold regular
-cat .hg/patches/git
+cat .hg/patches/git | filterpatch
cd ..
--- a/tests/test-mq-qfold.out Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-qfold.out Sun Feb 07 10:47:54 2010 -0500
@@ -29,6 +29,9 @@
% fold git patch into a regular patch, expect git patch
popping git
now at: regular
+# HG changeset patch
+# Parent
+
diff --git a/a b/a
--- a/a
+++ b/a
@@ -52,6 +55,9 @@
% fold regular patch into a git patch, expect git patch
popping regular
now at: git
+# HG changeset patch
+# Parent
+
diff --git a/a b/aa
copy from a
copy to aa
--- a/tests/test-mq-qnew Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-qnew Sun Feb 07 10:47:54 2010 -0500
@@ -1,73 +1,102 @@
#!/bin/sh
+catpatch() {
+ cat $1 | sed -e "s/^\(# Parent \).*/\1/"
+}
+
echo "[extensions]" >> $HGRCPATH
echo "mq=" >> $HGRCPATH
-hg init mq
-cd mq
+runtest() {
+ hg init mq
+ cd mq
-echo a > a
-hg ci -Ama
+ echo a > a
+ hg ci -Ama
-echo '% qnew should refuse bad patch names'
-hg qnew series
-hg qnew status
-hg qnew guards
-hg qnew .hgignore
+ echo '% qnew should refuse bad patch names'
+ hg qnew series
+ hg qnew status
+ hg qnew guards
+ hg qnew .hgignore
-hg qinit -c
+ hg qinit -c
-echo '% qnew with uncommitted changes'
-echo a > somefile
-hg add somefile
-hg qnew uncommitted.patch
-hg st
-hg qseries
+ echo '% qnew with uncommitted changes'
+ echo a > somefile
+ hg add somefile
+ hg qnew uncommitted.patch
+ hg st
+ hg qseries
+
+ echo '% qnew implies add'
+ hg -R .hg/patches st
-echo '% qnew implies add'
-hg -R .hg/patches st
+ echo '% qnew missing'
+ hg qnew missing.patch missing
+
+ echo '% qnew -m'
+ hg qnew -m 'foo bar' mtest.patch
+ catpatch .hg/patches/mtest.patch
-echo '% qnew missing'
-hg qnew missing.patch missing
+ echo '% qnew twice'
+ hg qnew first.patch
+ hg qnew first.patch
-echo '% qnew -m'
-hg qnew -m 'foo bar' mtest.patch
-cat .hg/patches/mtest.patch
+ touch ../first.patch
+ hg qimport ../first.patch
-echo '% qnew twice'
-hg qnew first.patch
-hg qnew first.patch
-
-touch ../first.patch
-hg qimport ../first.patch
+ echo '% qnew -f from a subdirectory'
+ hg qpop -a
+ mkdir d
+ cd d
+ echo b > b
+ hg ci -Am t
+ echo b >> b
+ hg st
+ hg qnew -g -f p
+ catpatch ../.hg/patches/p
-echo '% qnew -f from a subdirectory'
-hg qpop -a
-mkdir d
-cd d
-echo b > b
-hg ci -Am t
-echo b >> b
-hg st
-hg qnew -g -f p
-cat ../.hg/patches/p
+ echo '% qnew -u with no username configured'
+ HGUSER= hg qnew -u blue red
+ catpatch ../.hg/patches/red
-echo '% qnew -u with no username configured'
-HGUSER= hg qnew -u blue red
-cat ../.hg/patches/red
+ echo '% fail when trying to import a merge'
+ hg init merge
+ cd merge
+ touch a
+ hg ci -Am null
+ echo a >> a
+ hg ci -m a
+ hg up -r 0
+ echo b >> a
+ hg ci -m b
+ hg merge -f 1
+ hg resolve --mark a
+ hg qnew -f merge
+
+ cd ../../..
+ rm -r mq
+}
+
-echo '% fail when trying to import a merge'
-hg init merge
-cd merge
-touch a
-hg ci -Am null
-echo a >> a
-hg ci -m a
-hg up -r 0
-echo b >> a
-hg ci -m b
-hg merge -f 1
-hg resolve --mark a
-hg qnew -f merge
+echo '%%% plain headers'
+
+echo "[mq]" >> $HGRCPATH
+echo "plain=true" >> $HGRCPATH
+
+mkdir sandbox
+(cd sandbox ; runtest)
+rm -r sandbox
+
+
+echo '%%% hg headers'
+
+echo "plain=false" >> $HGRCPATH
+
+mkdir sandbox
+(cd sandbox ; runtest)
+rm -r sandbox
+
exit 0
--- a/tests/test-mq-qnew.out Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-qnew.out Sun Feb 07 10:47:54 2010 -0500
@@ -1,3 +1,4 @@
+%%% plain headers
adding a
% qnew should refuse bad patch names
abort: "series" cannot be used as the name of a patch
@@ -44,3 +45,55 @@
0 files updated, 0 files merged, 0 files removed, 1 files unresolved
use 'hg resolve' to retry unresolved file merges or 'hg update -C' to abandon
abort: cannot manage merge changesets
+%%% hg headers
+adding a
+% qnew should refuse bad patch names
+abort: "series" cannot be used as the name of a patch
+abort: "status" cannot be used as the name of a patch
+abort: "guards" cannot be used as the name of a patch
+abort: ".hgignore" cannot be used as the name of a patch
+% qnew with uncommitted changes
+uncommitted.patch
+% qnew implies add
+A .hgignore
+A series
+A uncommitted.patch
+% qnew missing
+abort: missing: No such file or directory
+% qnew -m
+# HG changeset patch
+# Parent
+foo bar
+
+% qnew twice
+abort: patch "first.patch" already exists
+abort: patch "first.patch" already exists
+% qnew -f from a subdirectory
+popping first.patch
+popping mtest.patch
+popping uncommitted.patch
+patch queue now empty
+adding d/b
+M d/b
+# HG changeset patch
+# Parent
+diff --git a/d/b b/d/b
+--- a/d/b
++++ b/d/b
+@@ -1,1 +1,2 @@
+ b
++b
+% qnew -u with no username configured
+# HG changeset patch
+# Parent
+# User blue
+% fail when trying to import a merge
+adding a
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+created new head
+merging a
+warning: conflicts during merge.
+merging a failed!
+0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+use 'hg resolve' to retry unresolved file merges or 'hg update -C' to abandon
+abort: cannot manage merge changesets
--- a/tests/test-mq-qpush-fail Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-qpush-fail Sun Feb 07 10:47:54 2010 -0500
@@ -29,7 +29,7 @@
hg add bar
hg qrefresh -m 'patch 2'
-hg qnew bad-patch
+hg qnew --config 'mq.plain=true' bad-patch
echo >> foo
hg qrefresh
--- a/tests/test-mq-qrefresh Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-qrefresh Sun Feb 07 10:47:54 2010 -0500
@@ -3,6 +3,10 @@
echo "[extensions]" >> $HGRCPATH
echo "mq=" >> $HGRCPATH
+catpatch() {
+ cat $1 | sed -e "s/^\(# Parent \).*/\1/"
+}
+
echo % init
hg init a
cd a
@@ -30,7 +34,7 @@
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
echo % patch file contents
-cat .hg/patches/mqbase | \
+catpatch .hg/patches/mqbase | \
sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
@@ -47,7 +51,7 @@
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
echo % patch file contents
-cat .hg/patches/mqbase | \
+catpatch .hg/patches/mqbase | \
sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
@@ -63,7 +67,7 @@
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
echo % patch file contents
-cat .hg/patches/mqbase | \
+catpatch .hg/patches/mqbase | \
sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
@@ -79,7 +83,7 @@
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
echo % patch file contents
-cat .hg/patches/mqbase | \
+catpatch .hg/patches/mqbase | \
sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
@@ -98,7 +102,7 @@
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
echo % -- patch file content
-cat .hg/patches/mqbase | \
+catpatch .hg/patches/mqbase | \
sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
hg st
@@ -176,7 +180,7 @@
echo '% b after refresh'
cat b
echo '% patch file after refresh'
-cat .hg/patches/patch
+catpatch .hg/patches/patch
cd ..
--- a/tests/test-mq-qrefresh.out Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-qrefresh.out Sun Feb 07 10:47:54 2010 -0500
@@ -31,6 +31,8 @@
-base
+patched
% patch file contents
+# HG changeset patch
+# Parent
mqbase
diff -r b55ecdccb5cf 1/base
@@ -73,6 +75,8 @@
-base
+patched
% patch file contents
+# HG changeset patch
+# Parent
mqbase
diff -r b55ecdccb5cf 1/base
@@ -109,6 +113,8 @@
-base
+patched
% patch file contents
+# HG changeset patch
+# Parent
mqbase
diff -r b55ecdccb5cf 1/base
@@ -145,6 +151,8 @@
-base
+patched
% patch file contents
+# HG changeset patch
+# Parent
mqbase
diff -r b55ecdccb5cf 1/base
@@ -181,6 +189,8 @@
@@ -0,0 +1,1 @@
+orphan
% -- patch file content
+# HG changeset patch
+# Parent
mqbase
diff -r b55ecdccb5cf 1/base
@@ -273,6 +283,9 @@
b
b
% patch file after refresh
+# HG changeset patch
+# Parent
+
diff -r 1a60229be7ac b
--- a/b
+++ b/b
--- a/tests/test-mq-symlinks Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-mq-symlinks Sun Feb 07 10:47:54 2010 -0500
@@ -48,7 +48,7 @@
cat s
hg st
-echo '% test symlink removal'
+echo '% test symlink removal'
hg qnew removesl.patch
hg rm a
hg qrefresh --git
--- a/tests/test-rebase-mq Mon Feb 08 19:44:04 2010 +0100
+++ b/tests/test-rebase-mq Sun Feb 07 10:47:54 2010 -0500
@@ -5,6 +5,9 @@
echo "rebase=" >> $HGRCPATH
echo "mq=" >> $HGRCPATH
+echo "[mq]" >> $HGRCPATH
+echo "plain=true" >> $HGRCPATH
+
filterpatch()
{
sed -e "s/^\(# Date\).*/\1/" \