[PATCH 1 of 1] mq: add parent node IDs to MQ patches on qrefresh/qnew
Steve Losh
steve at stevelosh.com
Sun Feb 7 17:27:19 CST 2010
# HG changeset patch
# User Steve Losh <steve at stevelosh.com>
# Date 1265557674 18000
# Node ID d278169e766357baf21b67e7d1919d5d02438268
# Parent 9b87c5f4c634b9718940e6380a62d7fcf1bcddaf
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.
Tests have been updated to reflect the new behavior and test it.
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -61,21 +61,21 @@
self.rev, self.name = fields
else:
self.rev, self.name = None, None
else:
self.rev, self.name = rev, name
def __str__(self):
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]
if (l.startswith("diff -") or
l.startswith("Index:") or
l.startswith("===========")):
del lines[-1]
else:
break
def eatempty(lines):
@@ -83,20 +83,21 @@
l = lines[-1]
if re.match('\s*$', l):
del lines[-1]
else:
break
message = []
comments = []
user = None
date = None
+ parent = None
format = None
subject = None
diffstart = 0
for line in file(pf):
line = line.rstrip()
if line.startswith('diff --git'):
diffstart = 2
break
if diffstart:
@@ -105,34 +106,40 @@
break
if line.startswith("--- "):
diffstart = 1
continue
elif format == "hgpatch":
# parse values when importing the result of an hg export
if line.startswith("# User "):
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
elif line == '# HG changeset patch':
message = []
format = "hgpatch"
elif (format != "tagdone" and (line.startswith("Subject: ") or
line.startswith("subject: "))):
subject = line[9:]
format = "tag"
elif (format != "tagdone" and (line.startswith("From: ") or
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
format = "tagdone"
elif message or line:
message.append(line)
comments.append(line)
eatdiff(message)
eatdiff(comments)
@@ -141,48 +148,59 @@
# make sure message isn't empty
if format and format.startswith("tag") and subject:
message.insert(0, "")
message.insert(0, subject)
self.message = message
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):
try:
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, '']
self.comments = tmp + self.comments
self.user = user
def setdate(self, date):
if not self.updateheader(['Date: ', '# Date '], date):
try:
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()
self.message = [message]
self.comments += self.message
def updateheader(self, prefixes, new):
'''Update all references to a field in the patch header.
Return whether the field is present.'''
res = False
@@ -238,20 +256,21 @@
self.active_guards = None
self.guards_dirty = False
# Handle mq.git as a bool with extended values
try:
gitmode = ui.configbool('mq', 'git', None)
if gitmode is None:
raise error.ConfigError()
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):
if os.path.exists(self.join(self.status_path)):
lines = self.opener(self.status_path).read().splitlines()
return [statusentry(l) for l in lines]
return []
@util.propertycache
def full_series(self):
@@ -502,21 +521,21 @@
self.strip(repo, n, update=False, backup='strip')
ctx = repo[rev]
ret = hg.merge(repo, rev)
if ret:
raise util.Abort(_("update returned %d") % ret)
n = repo.commit(ctx.description(), ctx.user(), force=True)
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)
diffopts = self.patchopts(diffopts, patch)
patchf = self.opener(patch, "w")
comments = str(ph)
if comments:
patchf.write(comments)
self.printdiff(repo, diffopts, head, n, fp=patchf)
patchf.close()
@@ -632,21 +651,21 @@
n = None
for patchname in series:
pushable, reason = self.pushable(patchname)
if not pushable:
self.explain_pushable(patchname, all_patches=True)
continue
self.ui.status(_("applying %s\n") % patchname)
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
break
message = ph.message
if not message:
message = "imported patch %s\n" % patchname
else:
if list:
@@ -824,28 +843,34 @@
if len(repo[None].parents()) > 1:
raise util.Abort(_('cannot manage merge changesets'))
commitfiles = m + a + r
self.check_toppatch(repo)
insert = self.full_series_end()
wlock = repo.wlock()
try:
# 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)
n = repo.commit(commitmsg, user, date, match=match, force=True)
if n is None:
raise util.Abort(_("repo commit failed"))
try:
self.full_series[insert:insert] = [patchfn]
self.applied.append(statusentry(hex(n), patchfn))
self.parse_series()
@@ -1207,28 +1232,29 @@
try:
self.check_toppatch(repo)
(top, patchfn) = (self.applied[-1].rev, self.applied[-1].name)
top = bin(top)
if repo.changelog.heads(top) != [top]:
raise util.Abort(_("cannot refresh a revision with children"))
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)
if newuser:
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)
comments = str(ph)
if comments:
patchf.write(comments)
# update the dirstate in place, strip off the qtip commit
# and then commit.
@@ -1399,21 +1425,21 @@
pushable, reason = self.pushable(i)
if pushable:
unapplied.append((i, self.series[i]))
self.explain_pushable(i)
return unapplied
def qseries(self, repo, missing=None, start=0, length=None, status=None,
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
if width > 0:
msg = util.ellipsis(msg, width)
else:
msg = ''
msg = "%s%s: %s" % (pfx, patchname, msg)
else:
msg = pfx + patchname
@@ -2005,21 +2031,21 @@
"""
q = repo.mq
message = cmdutil.logmessage(opts)
if opts['edit']:
if not q.applied:
ui.write(_("no patches applied\n"))
return 1
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)
q.save_dirty()
return ret
def diff(ui, repo, *pats, **opts):
"""diff of the current patch and subsequent modifications
Shows a diff which includes the current patch as well as any
@@ -2067,31 +2093,31 @@
for f in files:
p = q.lookup(f)
if p in patches or p == parent:
ui.warn(_('Skipping already folded patch %s') % p)
if q.isapplied(p):
raise util.Abort(_('qfold cannot fold already applied patch %s') % p)
patches.append(p)
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)
(patchsuccess, files, fuzz) = q.patch(repo, pf)
if not patchsuccess:
raise util.Abort(_('Error folding patch %s') % p)
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('* * *')
message.extend(msg)
message = '\n'.join(message)
if opts['edit']:
message = ui.edit(message, user or ui.username())
diffopts = q.patchopts(q.diffopts(), *patches)
@@ -2160,21 +2186,21 @@
"""print the header of the topmost or specified patch"""
q = repo.mq
if patch:
patch = q.lookup(patch)
else:
if not q.applied:
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')
def lastsavename(path):
(directory, base) = os.path.split(path)
names = os.listdir(directory)
namere = re.compile("%s.([0-9]+)" % base)
maxindex = None
maxname = None
for f in names:
diff --git a/tests/test-mq b/tests/test-mq
--- a/tests/test-mq
+++ b/tests/test-mq
@@ -3,20 +3,23 @@
checkundo()
{
if [ -f .hg/store/undo ]; then
echo ".hg/store/undo still exists after $1"
fi
}
echo "[extensions]" >> $HGRCPATH
echo "mq=" >> $HGRCPATH
+echo "[mq]" >> $HGRCPATH
+echo "plain=true" >> $HGRCPATH
+
echo % help
hg help mq
hg init a
cd a
echo a > a
hg ci -Ama
hg clone . ../k
diff --git a/tests/test-mq-git b/tests/test-mq-git
--- a/tests/test-mq-git
+++ b/tests/test-mq-git
@@ -18,21 +18,21 @@
echo '% git=auto: git patch creation with copy'
hg cp a b
hg qnew -d '0 0' -f copy
cat .hg/patches/copy
echo '% git=auto: git patch when using --git'
echo regular > regular
hg add regular
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 ..
hg init repo-keep
cd repo-keep
echo '[mq]' > .hg/hgrc
echo 'git = KEEP' >> .hg/hgrc
echo '% git=keep: git patch with --git'
echo a > a
hg add a
diff --git a/tests/test-mq-git.out b/tests/test-mq-git.out
--- a/tests/test-mq-git.out
+++ b/tests/test-mq-git.out
@@ -1,98 +1,108 @@
% git=auto: regular patch creation
# HG changeset patch
+# Parent 0000000000000000000000000000000000000000
# Date 0 0
diff -r 000000000000 -r ef8dafc9fa4c a
--- /dev/null
+++ b/a
@@ -0,0 +1,1 @@
+a
% git=auto: git patch creation with copy
# HG changeset patch
+# Parent ef8dafc9fa4caff80f6e243eb0171bcd60c455b4
# Date 0 0
diff --git a/a b/b
copy from a
copy to b
% git=auto: git patch when using --git
# HG changeset patch
+# Parent 2962f232b49d41ebc26c591ec8d556724be213ab
# Date 0 0
diff --git a/regular b/regular
new file mode 100644
--- /dev/null
+++ b/regular
@@ -0,0 +1,1 @@
+regular
% git=auto: regular patch after qrefresh without --git
# HG changeset patch
+# Parent 2962f232b49d41ebc26c591ec8d556724be213ab
# Date 0 0
diff -r 2962f232b49d regular
--- /dev/null
+++ b/regular
@@ -0,0 +1,1 @@
+regular
% git=keep: git patch with --git
# HG changeset patch
+# Parent 0000000000000000000000000000000000000000
# Date 0 0
diff --git a/a b/a
new file mode 100644
--- /dev/null
+++ b/a
@@ -0,0 +1,1 @@
+a
% git=keep: git patch after qrefresh without --git
# HG changeset patch
+# Parent 0000000000000000000000000000000000000000
# Date 0 0
diff --git a/a b/a
new file mode 100644
--- /dev/null
+++ b/a
@@ -0,0 +1,2 @@
+a
+a
% git=yes: git patch
# HG changeset patch
+# Parent 0000000000000000000000000000000000000000
# Date 0 0
diff --git a/a b/a
new file mode 100644
--- /dev/null
+++ b/a
@@ -0,0 +1,1 @@
+a
% git=yes: git patch after qrefresh
# HG changeset patch
+# Parent 0000000000000000000000000000000000000000
# Date 0 0
diff --git a/a b/a
new file mode 100644
--- /dev/null
+++ b/a
@@ -0,0 +1,2 @@
+a
+a
% git=no: regular patch with copy
# HG changeset patch
+# Parent ef8dafc9fa4caff80f6e243eb0171bcd60c455b4
# Date 0 0
diff -r ef8dafc9fa4c -r 110cde11d262 b
--- /dev/null
+++ b/b
@@ -0,0 +1,1 @@
+a
% git=no: regular patch after qrefresh with copy
# HG changeset patch
+# Parent ef8dafc9fa4caff80f6e243eb0171bcd60c455b4
# Date 0 0
diff -r ef8dafc9fa4c b
--- /dev/null
+++ b/b
@@ -0,0 +1,1 @@
+a
diff -r ef8dafc9fa4c c
--- /dev/null
+++ b/c
diff --git a/tests/test-mq-header-date b/tests/test-mq-header-date
--- a/tests/test-mq-header-date
+++ b/tests/test-mq-header-date
@@ -1,177 +1,217 @@
#!/bin/sh
echo "[extensions]" >> $HGRCPATH
echo "mq=" >> $HGRCPATH
echo "[diff]" >> $HGRCPATH
echo "nodates=true" >> $HGRCPATH
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() {
catpatch $1
hg log --template "{rev}: {desc} - {author}\n"
}
catlogd() {
catpatch $1
hg log --template "{rev}: {desc} - {author} - {date}\n"
}
drop() {
hg qpop
hg qdel $1.patch
}
+runtest() {
+ echo ==== init
+ hg init a
+ cd a
+ hg qinit
-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
-echo ==== qref -d
-hg qref -d '9 0'
-catlog 4
+ drop 4
-drop 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
-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 ==== hg qref
+ echo "5" >5
+ hg add
+ hg qref
+ catlogd 5
-echo ==== hg qref
-echo "5" >5
-hg add
-hg qref
-catlogd 5
+ echo ==== hg qref -d
+ hg qref -d '11 0'
+ catlogd 5
-echo ==== hg qref -d
-hg qref -d '11 0'
-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 ==== qnew -u
-hg qnew -u jane 6.patch
-echo "6" >6
-hg add
-hg qref
-catlog 6
+ echo ==== hg qref
+ echo "6" >6
+ hg add
+ hg qref
+ catlogd 6
-echo ==== qref -d
-hg qref -d '12 0'
-catlog 6
+ echo ==== hg qref -d
+ hg qref -d '13 0'
+ catlogd 6
-drop 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
-echo ==== qref -u
-hg qref -u john
-catlogd 7
+ drop 6
-echo ==== qnew
-hg qnew 8.patch
-echo "8" >8
-hg add
-hg qref
-catlog 8
+ echo ==== qnew -d
+ hg qnew -d '13 0' 7.patch
+ echo "7" >7
+ hg add
+ hg qref
+ catlog 7
-echo ==== qref -u -d
-hg qref -u john -d '14 0'
-catlog 8
+ echo ==== qref -u
+ hg qref -u john
+ catlogd 7
-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 ==== "qpop -a / qpush -a"
-hg qpop -a
-hg qpush -a
-hg log --template "{rev}: {desc} - {author} - {date}\n"
+ 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 ======= 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
diff --git a/tests/test-mq-header-date.out b/tests/test-mq-header-date.out
--- a/tests/test-mq-header-date.out
+++ b/tests/test-mq-header-date.out
@@ -1,111 +1,102 @@
+======= 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
+++ b/1
@@ -0,0 +1,1 @@
+1
0: [mq]: 1.patch - test - 3.00
==== qref -d
-# HG changeset patch
-# Date 4 0
+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
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
-
+Date: 5 0
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
-# Date 6 0
+Date: 6 0
Three
1: Three - test - 6.00
0: [mq]: 1.patch - test - 4.00
==== qref
adding 3
-# HG changeset patch
-# Date 6 0
+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
-# Date 6 0
+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
-# Date 7 0
+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
-# Date 8 0
+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
@@ -115,23 +106,21 @@
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
-
+Date: 9 0
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
@@ -141,42 +130,81 @@
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
From: jane
diff -r ... 6
--- /dev/null
+++ b/6
@@ -0,0 +1,1 @@
+6
3: [mq]: 6.patch - jane
@@ -193,36 +221,34 @@
@@ -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
-# Date 13 0
+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
-# Date 13 0
+From: john
+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
@@ -232,24 +258,22 @@
--- /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
-
+Date: 14 0
+From: john
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
@@ -264,24 +288,22 @@
--- /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
-
+Date: 15 0
+From: john
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
@@ -297,10 +319,380 @@
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
+======= 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
diff --git a/tests/test-mq-header-from b/tests/test-mq-header-from
--- a/tests/test-mq-header-from
+++ b/tests/test-mq-header-from
@@ -1,107 +1,151 @@
#!/bin/sh
echo "[extensions]" >> $HGRCPATH
echo "mq=" >> $HGRCPATH
echo "[diff]" >> $HGRCPATH
echo "nodates=true" >> $HGRCPATH
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 ==== init
-hg init a
-cd a
-hg qinit
+ echo ==== qnew -U
+ hg qnew -U 1.patch
+ catlog 1
-echo ==== qnew -U
-hg qnew -U 1.patch
-catlog 1
+ echo ==== qref
+ echo "1" >1
+ hg add
+ hg qref
+ catlog 1
-echo ==== qref
-echo "1" >1
-hg add
-hg qref
-catlog 1
+ echo ==== qref -u
+ hg qref -u mary
+ 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 ==== qnew
-hg qnew 2.patch
-echo "2" >2
-hg add
-hg qref
-catlog 2
+ echo ==== qref -u
+ hg qref -u jane
+ 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 ==== 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
-echo "3" >3
-hg add
-hg qref
-catlog 3
+ echo ==== qref -m
+ hg qref -m "Drei"
+ catlog 3
-echo ==== qref -m
-hg qref -m "Drei"
-catlog 3
+ echo ==== qref -u
+ hg qref -u mary
+ 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 ==== 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 ==== qnew -m
-hg qnew -m "Four" 4.patch
-echo "4" >4
-hg add
-hg qref
-catlog 4
+ echo ==== qref -u
+ hg qref -u jane
+ 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 ==== 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
+ echo ==== hg qref
+ echo "5" >5
+ hg add
+ hg qref
+ 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
-catlog 5
+ echo ==== hg qref -u
+ hg qref -u johndeere
+ 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 ==== "qpop -a / qpush -a"
-hg qpop -a
-hg qpush -a
-hg log --template "{rev}: {desc} - {author}\n"
+ 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 ======= 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
+
+runtest
\ No newline at end of file
diff --git a/tests/test-mq-header-from.out b/tests/test-mq-header-from.out
--- a/tests/test-mq-header-from.out
+++ b/tests/test-mq-header-from.out
@@ -1,10 +1,11 @@
+======= plain headers
==== init
==== qnew -U
From: test
0: [mq]: 1.patch - test
==== qref
adding 1
From: test
diff -r ... 1
@@ -25,23 +26,21 @@
==== qnew
adding 2
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
-
+From: jane
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
From: test
@@ -98,109 +97,733 @@
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 4
+adding 4of
Four
-diff -r ... 4
+diff -r ... 4of
--- /dev/null
-+++ b/4
++++ b/4of
@@ -0,0 +1,1 @@
-+4
++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
-
+From: jane
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
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
-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
+======= 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 @@
++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
+==== 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
diff --git a/tests/test-mq-merge.out b/tests/test-mq-merge.out
--- a/tests/test-mq-merge.out
+++ b/tests/test-mq-merge.out
@@ -27,20 +27,23 @@
1 out of 1 hunks FAILED -- saving rejects to file a.rej
patch failed, unable to continue (try -v)
patch failed, rejects left in working dir
patch didn't work out, merging patcha
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
0 files updated, 2 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
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
@@ -1,1 +1,2 @@
-b
+a
+c
diff --git a/a b/aa
copy from a
copy to aa
diff --git a/tests/test-mq-qfold b/tests/test-mq-qfold
--- a/tests/test-mq-qfold
+++ b/tests/test-mq-qfold
@@ -5,20 +5,25 @@
echo "[mq]" >> $HGRCPATH
echo "git=keep" >> $HGRCPATH
filterdiff()
{
grep -v diff | \
sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
}
+filterpatch()
+{
+ sed -e "s/\(# Parent \).*/\1/"
+}
+
echo '% init'
hg init repo
cd repo
echo a > a
hg ci -Am adda
echo a >> a
hg qnew -f p1
echo b >> a
hg qnew -f p2
echo c >> a
@@ -36,26 +41,26 @@
hg diff -c . | filterdiff
hg revert -a --no-backup
echo '% fold git patch into a regular patch, expect git patch'
echo a >> a
hg qnew -f regular
hg cp a aa
hg qnew --git -f git
hg qpop
hg qfold git
-cat .hg/patches/regular
+cat .hg/patches/regular | filterpatch
hg qpop
hg qdel regular
echo '% fold regular patch into a git patch, expect git patch'
hg cp a aa
hg qnew --git -f git
echo b >> aa
hg qnew -f regular
hg qpop
hg qfold regular
-cat .hg/patches/git
+cat .hg/patches/git | filterpatch
cd ..
diff --git a/tests/test-mq-qfold.out b/tests/test-mq-qfold.out
--- a/tests/test-mq-qfold.out
+++ b/tests/test-mq-qfold.out
@@ -22,20 +22,23 @@
--- a/a
+++ b/a
@@ -1,1 +1,3 @@
a
+a
+b
reverting a
% 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
@@ -1,3 +1,4 @@
a
a
b
+a
diff --git a/a b/aa
copy from a
@@ -45,20 +48,23 @@
@@ -1,3 +1,4 @@
a
a
b
+a
popping regular
now at: p1
% 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/a
+++ b/aa
@@ -1,3 +1,4 @@
a
a
b
+b
diff --git a/tests/test-mq-qnew b/tests/test-mq-qnew
--- a/tests/test-mq-qnew
+++ b/tests/test-mq-qnew
@@ -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 missing'
+ hg qnew missing.patch missing
-echo '% qnew -m'
-hg qnew -m 'foo bar' mtest.patch
-cat .hg/patches/mtest.patch
+ echo '% qnew -m'
+ hg qnew -m 'foo bar' mtest.patch
+ catpatch .hg/patches/mtest.patch
-echo '% qnew twice'
-hg qnew first.patch
-hg qnew first.patch
+ echo '% qnew twice'
+ hg qnew first.patch
+ hg qnew first.patch
-touch ../first.patch
-hg qimport ../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
-cat ../.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
+ catpatch ../.hg/patches/p
-echo '% qnew -u with no username configured'
-HGUSER= hg qnew -u blue red
-cat ../.hg/patches/red
+ echo '% qnew -u with no username configured'
+ HGUSER= hg qnew -u blue red
+ catpatch ../.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
+ 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 '%%% 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
diff --git a/tests/test-mq-qnew.out b/tests/test-mq-qnew.out
--- a/tests/test-mq-qnew.out
+++ b/tests/test-mq-qnew.out
@@ -1,10 +1,11 @@
+%%% plain 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
@@ -37,10 +38,62 @@
% 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
+%%% 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
diff --git a/tests/test-mq-qpush-fail b/tests/test-mq-qpush-fail
--- a/tests/test-mq-qpush-fail
+++ b/tests/test-mq-qpush-fail
@@ -22,21 +22,21 @@
hg qnew patch1
echo >> foo
hg qrefresh -m 'patch 1'
hg qnew patch2
echo bar > bar
hg add bar
hg qrefresh -m 'patch 2'
-hg qnew bad-patch
+hg qnew --config 'mq.plain=true' bad-patch
echo >> foo
hg qrefresh
hg qpop -a
python -c 'print "\xe9"' > message
cat .hg/patches/bad-patch >> message
mv message .hg/patches/bad-patch
hg qpush -a && echo 'qpush succeded?!'
diff --git a/tests/test-mq-qrefresh b/tests/test-mq-qrefresh
--- a/tests/test-mq-qrefresh
+++ b/tests/test-mq-qrefresh
@@ -1,15 +1,19 @@
#!/bin/sh
echo "[extensions]" >> $HGRCPATH
echo "mq=" >> $HGRCPATH
+catpatch() {
+ cat $1 | sed -e "s/^\(# Parent \).*/\1/"
+}
+
echo % init
hg init a
cd a
echo % commit
mkdir 1 2
echo 'base' > 1/base
echo 'base' > 2/base
hg ci -Ambase -d '1 0'
@@ -23,89 +27,89 @@
echo % qdiff
hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
echo % qdiff dirname
hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-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/"
echo % qrefresh 1
echo 'patched again' > base
hg qrefresh 1
echo % qdiff
hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
echo % qdiff dirname
hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-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/"
echo % qrefresh . in subdir
( cd 1 ; hg qrefresh . )
echo % qdiff
hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
echo % qdiff dirname
hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-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/"
echo % qrefresh in hg-root again
hg qrefresh
echo % qdiff
hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/"
echo % qdiff dirname
hg qdiff . | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-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/"
echo
echo % qrefresh --short tests:
echo 'orphan' > orphanchild
hg add orphanchild
echo % - add 1/base and 2/base one by one
hg qrefresh nonexistingfilename # clear patch
hg qrefresh --short 1/base
hg qrefresh --short 2/base
echo % -- qdiff output
hg qdiff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-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
echo % -- diff shows what is not in patch
hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/^\(diff\).*/\1/"
echo % - before starting exclusive tests
sed -n '/^diff/s/diff -r [^ ]* //p' .hg/patches/mqbase
@@ -169,21 +173,21 @@
hg ci -qAm addc
hg up -qC 1
echo '% refresh with tip != qtip'
hg --config diff.nodates=1 qrefresh -I b 2>&1 \
| sed 's/saving bundle.*/saving bundle.../g'
echo '% status after refresh'
hg st
echo '% b after refresh'
cat b
echo '% patch file after refresh'
-cat .hg/patches/patch
+catpatch .hg/patches/patch
cd ..
echo % issue1441 with git patches
hg init repo-1441-git
cd repo-1441-git
echo "[diff]" >> .hg/hgrc
echo "git=True" >> .hg/hgrc
echo a > a
hg add a
diff --git a/tests/test-mq-qrefresh.out b/tests/test-mq-qrefresh.out
--- a/tests/test-mq-qrefresh.out
+++ b/tests/test-mq-qrefresh.out
@@ -24,20 +24,22 @@
@@ -1,1 +1,1 @@
-base
+patched
diff -r b55ecdccb5cf 2/base
--- a/2/base
+++ b/2/base
@@ -1,1 +1,1 @@
-base
+patched
% patch file contents
+# HG changeset patch
+# Parent
mqbase
diff -r b55ecdccb5cf 1/base
--- a/1/base
+++ b/1/base
@@ -1,1 +1,1 @@
-base
+patched
diff -r b55ecdccb5cf 2/base
--- a/2/base
@@ -66,20 +68,22 @@
@@ -1,1 +1,1 @@
-base
+patched
diff -r b55ecdccb5cf 2/base
--- a/2/base
+++ b/2/base
@@ -1,1 +1,1 @@
-base
+patched
% patch file contents
+# HG changeset patch
+# Parent
mqbase
diff -r b55ecdccb5cf 1/base
--- a/1/base
+++ b/1/base
@@ -1,1 +1,1 @@
-base
+patched
% qrefresh . in subdir
% qdiff
@@ -102,20 +106,22 @@
@@ -1,1 +1,1 @@
-base
+patched
diff -r b55ecdccb5cf 2/base
--- a/2/base
+++ b/2/base
@@ -1,1 +1,1 @@
-base
+patched
% patch file contents
+# HG changeset patch
+# Parent
mqbase
diff -r b55ecdccb5cf 1/base
--- a/1/base
+++ b/1/base
@@ -1,1 +1,1 @@
-base
+patched
% qrefresh in hg-root again
% qdiff
@@ -138,20 +144,22 @@
@@ -1,1 +1,1 @@
-base
+patched
diff -r b55ecdccb5cf 2/base
--- a/2/base
+++ b/2/base
@@ -1,1 +1,1 @@
-base
+patched
% patch file contents
+# HG changeset patch
+# Parent
mqbase
diff -r b55ecdccb5cf 1/base
--- a/1/base
+++ b/1/base
@@ -1,1 +1,1 @@
-base
+patched
diff -r b55ecdccb5cf 2/base
--- a/2/base
@@ -174,20 +182,22 @@
+++ b/2/base
@@ -1,1 +1,1 @@
-base
+patched
diff -r b55ecdccb5cf orphanchild
--- /dev/null
+++ b/orphanchild
@@ -0,0 +1,1 @@
+orphan
% -- patch file content
+# HG changeset patch
+# Parent
mqbase
diff -r b55ecdccb5cf 1/base
--- a/1/base
+++ b/1/base
@@ -1,1 +1,1 @@
-base
+patched
diff -r b55ecdccb5cf 2/base
--- a/2/base
@@ -266,20 +276,23 @@
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
% status after refresh
M a
% b after refresh
b
b
% patch file after refresh
+# HG changeset patch
+# Parent
+
diff -r 1a60229be7ac b
--- a/b
+++ b/b
@@ -1,1 +1,2 @@
b
+b
% issue1441 with git patches
diff --git a/b b/b
new file mode 100644
--- /dev/null
diff --git a/tests/test-mq-symlinks b/tests/test-mq-symlinks
--- a/tests/test-mq-symlinks
+++ b/tests/test-mq-symlinks
@@ -41,17 +41,17 @@
hg add s
hg qnew --git -f addlink
rm s
echo sss > s
hg qnew --git -f replacelinkwithfile
hg qpop
hg qpush
cat s
hg st
-echo '% test symlink removal'
+echo '% test symlink removal'
hg qnew removesl.patch
hg rm a
hg qrefresh --git
hg qpop
hg qpush
hg st -c
diff --git a/tests/test-rebase-mq b/tests/test-rebase-mq
--- a/tests/test-rebase-mq
+++ b/tests/test-rebase-mq
@@ -1,17 +1,20 @@
#!/bin/sh
echo "[extensions]" >> $HGRCPATH
echo "graphlog=" >> $HGRCPATH
echo "rebase=" >> $HGRCPATH
echo "mq=" >> $HGRCPATH
+echo "[mq]" >> $HGRCPATH
+echo "plain=true" >> $HGRCPATH
+
filterpatch()
{
sed -e "s/^\(# Date\).*/\1/" \
-e "s/^\(# Node ID\).*/\1/" \
-e "s/^\(# Parent\).*/\1/" \
-e "s/^\(diff -r \)\([a-f0-9]* \)\(-r \)\([a-f0-9]* \)/\1x \3y /" \
-e "s/^\(diff -r \)\([a-f0-9]* \)/\1x /" \
-e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" \
-e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/"
}
More information about the Mercurial-devel
mailing list