Patchwork [5,of,9,PoC] mq2: obsolete old qrefresh changesets instead of stripping them

login
register
mail settings
Submitter Mads Kiilerich
Date Aug. 29, 2014, 8:59 a.m.
Message ID <f51d4707ff2686d3dbdf.1409302762@localhost.localdomain>
Download mbox | patch
Permalink /patch/5617/
State Changes Requested
Headers show

Comments

Mads Kiilerich - Aug. 29, 2014, 8:59 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1409301991 -7200
#      Fri Aug 29 10:46:31 2014 +0200
# Node ID f51d4707ff2686d3dbdf9de9062f1c035c343083
# Parent  45d9a0aa776748ca9ef180e92ec525949eb2d5b1
mq2: obsolete old qrefresh changesets instead of stripping them

Enabling obsolete changes some revision numbers and also changes how clone
works.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -72,6 +72,9 @@  from mercurial import localrepo
 from mercurial import subrepo
 import os, re, errno, shutil
 
+import mercurial.obsolete
+mercurial.obsolete._enabled = True
+
 seriesopts = [('s', 'summary', None, _('print first line of patch header'))]
 
 cmdtable = {}
@@ -852,7 +855,9 @@  class queue(object):
             n = newcommit(repo, None, message, ph.user, ph.date, match=match,
                           force=True)
             if repo['tip'] == oldtip:
-                raise util.Abort(_("qpush exactly duplicates child changeset"))
+                self.ui.debug(_("qpush duplicated existing changeset %s\n") % short(n))
+            else:
+                self.ui.debug(_("qpush created %s\n") % short(n))
             if n is None:
                 raise util.Abort(_("repository commit failed"))
 
@@ -1129,7 +1134,7 @@  class queue(object):
                         if date:
                             p.write("# Date %s %s\n\n" % date)
 
-                    nctx = repo[n]
+                    nctx = repo.unfiltered()[n]
                     if nctx.description() != defaultmsg.rstrip():
                         msg = nctx.description() + "\n\n"
                         p.write(msg)
@@ -1671,7 +1676,7 @@  class queue(object):
                 repo.setparents(*cparents)
                 self.applied.pop()
                 self.applieddirty = True
-                strip(self.ui, repo, [top], update=False, backup=False)
+                self.ui.debug('not stripping %s\n' % short(top))
             except: # re-raises
                 repo.dirstate.invalidate()
                 raise
@@ -1710,7 +1715,7 @@  class queue(object):
                 c = [list(x) for x in refreshchanges]
                 if inclsubs:
                     self.putsubstate2changes(substatestate, c)
-                chunks = patchmod.diff(repo, patchparent,
+                chunks = patchmod.diff(repo.unfiltered(), patchparent,
                                        changes=c, opts=diffopts)
                 ph.setnodeid(hex(n))
                 comments = str(ph)
@@ -1726,6 +1731,15 @@  class queue(object):
                 marks.write()
 
                 self.applied.append(statusentry(n, patchfn))
+
+                if n != top:
+                    self.ui.debug('obsoleting %s by %s\n' % (short(top), short(n)))
+                    tr = repo.transaction('qrefresh-obsolete')
+                    try:
+                        repo.obsstore.create(tr, top, [n])
+                        tr.close()
+                    finally:
+                        tr.release()
             except: # re-raises
                 ctx = repo[cparents[0]]
                 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
diff --git a/tests/test-mq-header-date.t b/tests/test-mq-header-date.t
--- a/tests/test-mq-header-date.t
+++ b/tests/test-mq-header-date.t
@@ -213,7 +213,7 @@ 
   +++ b/1
   @@ -0,0 +1,1 @@
   +1
-  0: [mq]: 1.patch - test - 3.00
+  1: [mq]: 1.patch - test - 3.00
   ==== qref -d
   Date: 4 0
   
@@ -222,7 +222,7 @@ 
   +++ b/1
   @@ -0,0 +1,1 @@
   +1
-  0: [mq]: 1.patch - test - 4.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qnew
   adding 2
   Date: 1 0
@@ -232,8 +232,8 @@ 
   +++ b/2
   @@ -0,0 +1,1 @@
   +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - test
+  4: [mq]: 2.patch - test
+  2: [mq]: 1.patch - test
   ==== qref -d
   Date: 5 0
   
@@ -242,8 +242,8 @@ 
   +++ b/2
   @@ -0,0 +1,1 @@
   +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - test
+  5: [mq]: 2.patch - test
+  2: [mq]: 1.patch - test
   popping 2.patch
   now at: 1.patch
   ==== qnew -d -m
@@ -251,8 +251,8 @@ 
   
   Three
   
-  1: Three - test - 6.00
-  0: [mq]: 1.patch - test - 4.00
+  5: Three - test - 6.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qref
   adding 3
   Date: 6 0
@@ -264,8 +264,8 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  1: Three - test - 6.00
-  0: [mq]: 1.patch - test - 4.00
+  6: Three - test - 6.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qref -m
   Date: 6 0
   
@@ -276,8 +276,8 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  1: Drei - test - 6.00
-  0: [mq]: 1.patch - test - 4.00
+  7: Drei - test - 6.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qref -d
   Date: 7 0
   
@@ -288,8 +288,8 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  1: Drei - test - 7.00
-  0: [mq]: 1.patch - test - 4.00
+  8: Drei - test - 7.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qref -d -m
   Date: 8 0
   
@@ -300,8 +300,8 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
+  9: Three (again) - test - 8.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qnew -m
   adding 4
   Date: 1 0
@@ -313,9 +313,9 @@ 
   +++ b/4
   @@ -0,0 +1,1 @@
   +4
-  2: Four - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
+  11: Four - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   ==== qref -d
   Date: 9 0
   
@@ -326,9 +326,9 @@ 
   +++ b/4
   @@ -0,0 +1,1 @@
   +4
-  2: Four - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
+  12: Four - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   popping 4.patch
   now at: 3.patch
   ==== qnew with HG header
@@ -338,9 +338,9 @@ 
   
   # 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
+  12: imported patch 5.patch - test - 10.00
+  9: Three (again) - test - 8.00
+  2: [mq]: 1.patch - test - 4.00
   ==== hg qref
   adding 5
   Date: 1 0
@@ -354,9 +354,9 @@ 
   +++ 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
+  13: [mq]: 5.patch - test - 10.00
+  9: Three (again) - test - 8.00
+  2: [mq]: 1.patch - test - 4.00
   ==== hg qref -d
   Date: 11 0
   
@@ -369,19 +369,19 @@ 
   +++ 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
+  14: [mq]: 5.patch - test - 11.00
+  9: Three (again) - test - 8.00
+  2: [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
+  15: imported patch 6.patch - test
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   ==== hg qref
   adding 6
   Date: 12 0
@@ -391,10 +391,10 @@ 
   +++ 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
+  16: [mq]: 6.patch - test - 12.00
+  14: [mq]: 5.patch - test - 11.00
+  9: Three (again) - test - 8.00
+  2: [mq]: 1.patch - test - 4.00
   ==== hg qref -d
   Date: 13 0
   
@@ -403,10 +403,10 @@ 
   +++ 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
+  17: [mq]: 6.patch - test - 13.00
+  14: [mq]: 5.patch - test - 11.00
+  9: Three (again) - test - 8.00
+  2: [mq]: 1.patch - test - 4.00
   popping 6.patch
   now at: 5.patch
   ==== qnew -u
@@ -419,10 +419,10 @@ 
   +++ 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
+  18: [mq]: 6.patch - jane
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   ==== qref -d
   From: jane
   Date: 12 0
@@ -432,10 +432,10 @@ 
   +++ 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
+  19: [mq]: 6.patch - jane
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   popping 6.patch
   now at: 5.patch
   ==== qnew -d
@@ -447,10 +447,10 @@ 
   +++ 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
+  20: [mq]: 7.patch - test
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   ==== qref -u
   From: john
   Date: 13 0
@@ -460,10 +460,10 @@ 
   +++ 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
+  21: [mq]: 7.patch - john - 13.00
+  14: [mq]: 5.patch - test - 11.00
+  9: Three (again) - test - 8.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qnew
   adding 8
   Date: 1 0
@@ -473,11 +473,11 @@ 
   +++ 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
+  23: [mq]: 8.patch - test
+  21: [mq]: 7.patch - john
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   ==== qref -u -d
   From: john
   Date: 14 0
@@ -487,11 +487,11 @@ 
   +++ 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
+  24: [mq]: 8.patch - john
+  21: [mq]: 7.patch - john
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   popping 8.patch
   now at: 7.patch
   ==== qnew -m
@@ -505,11 +505,11 @@ 
   +++ 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
+  25: Nine - test
+  21: [mq]: 7.patch - john
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   ==== qref -u -d
   From: john
   Date: 15 0
@@ -521,11 +521,11 @@ 
   +++ 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
+  26: Nine - john
+  21: [mq]: 7.patch - john
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   popping 9.patch
   now at: 7.patch
   ==== qpop -a / qpush -a
@@ -539,10 +539,10 @@ 
   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
+  5: imported patch 7.patch - john - 13.00
+  4: imported patch 5.patch - test - 11.00
+  3: Three (again) - test - 8.00
+  2: imported patch 1.patch - test - 4.00
   $ rm -r sandbox
 
 ======= hg headers
@@ -570,7 +570,7 @@ 
   +++ b/1
   @@ -0,0 +1,1 @@
   +1
-  0: [mq]: 1.patch - test - 3.00
+  1: [mq]: 1.patch - test - 3.00
   ==== qref -d
   # HG changeset patch
   # Node ID 4a67dfeea97489d65d35274ac4b91262efde2c6e
@@ -582,7 +582,7 @@ 
   +++ b/1
   @@ -0,0 +1,1 @@
   +1
-  0: [mq]: 1.patch - test - 4.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qnew
   adding 2
   # HG changeset patch
@@ -595,8 +595,8 @@ 
   +++ b/2
   @@ -0,0 +1,1 @@
   +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - test
+  4: [mq]: 2.patch - test
+  2: [mq]: 1.patch - test
   ==== qref -d
   # HG changeset patch
   # Node ID 1d9a6a118fd1d2b2f0d04bdebc451f8f655b1633
@@ -608,8 +608,8 @@ 
   +++ b/2
   @@ -0,0 +1,1 @@
   +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - test
+  5: [mq]: 2.patch - test
+  2: [mq]: 1.patch - test
   popping 2.patch
   now at: 1.patch
   ==== qnew -d -m
@@ -620,8 +620,8 @@ 
   
   Three
   
-  1: Three - test - 6.00
-  0: [mq]: 1.patch - test - 4.00
+  5: Three - test - 6.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qref
   adding 3
   # HG changeset patch
@@ -636,8 +636,8 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  1: Three - test - 6.00
-  0: [mq]: 1.patch - test - 4.00
+  6: Three - test - 6.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qref -m
   # HG changeset patch
   # Node ID 7ff7377793e36dff43543230decc31cb29da2752
@@ -651,8 +651,8 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  1: Drei - test - 6.00
-  0: [mq]: 1.patch - test - 4.00
+  7: Drei - test - 6.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qref -d
   # HG changeset patch
   # Node ID d89d3144f51897f68812b107802a98b5e0638d99
@@ -666,8 +666,8 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  1: Drei - test - 7.00
-  0: [mq]: 1.patch - test - 4.00
+  8: Drei - test - 7.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qref -d -m
   # HG changeset patch
   # Node ID b1b6b0fe0e6d78b1206ee2ff4b6bb713a395956a
@@ -681,8 +681,8 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  1: Three (again) - test - 8.00
-  0: [mq]: 1.patch - test - 4.00
+  9: Three (again) - test - 8.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qnew -m
   adding 4
   # HG changeset patch
@@ -697,9 +697,9 @@ 
   +++ b/4
   @@ -0,0 +1,1 @@
   +4
-  2: Four - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
+  11: Four - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   ==== qref -d
   # HG changeset patch
   # Node ID 1a651320cf8e3144a1a35a3c9d44890d0d7b847c
@@ -713,9 +713,9 @@ 
   +++ b/4
   @@ -0,0 +1,1 @@
   +4
-  2: Four - test
-  1: Three (again) - test
-  0: [mq]: 1.patch - test
+  12: Four - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   popping 4.patch
   now at: 3.patch
   ==== qnew with HG header
@@ -725,9 +725,9 @@ 
   
   # 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
+  12: imported patch 5.patch - test - 10.00
+  9: Three (again) - test - 8.00
+  2: [mq]: 1.patch - test - 4.00
   ==== hg qref
   adding 5
   Date: 1 0
@@ -742,9 +742,9 @@ 
   +++ 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
+  13: [mq]: 5.patch - test - 10.00
+  9: Three (again) - test - 8.00
+  2: [mq]: 1.patch - test - 4.00
   ==== hg qref -d
   Date: 11 0
   
@@ -758,19 +758,19 @@ 
   +++ 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
+  14: [mq]: 5.patch - test - 11.00
+  9: Three (again) - test - 8.00
+  2: [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
+  15: imported patch 6.patch - test
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   ==== hg qref
   adding 6
   Date: 12 0
@@ -780,10 +780,10 @@ 
   +++ 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
+  16: [mq]: 6.patch - test - 12.00
+  14: [mq]: 5.patch - test - 11.00
+  9: Three (again) - test - 8.00
+  2: [mq]: 1.patch - test - 4.00
   ==== hg qref -d
   Date: 13 0
   
@@ -792,10 +792,10 @@ 
   +++ 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
+  17: [mq]: 6.patch - test - 13.00
+  14: [mq]: 5.patch - test - 11.00
+  9: Three (again) - test - 8.00
+  2: [mq]: 1.patch - test - 4.00
   popping 6.patch
   now at: 5.patch
   ==== qnew -u
@@ -811,10 +811,10 @@ 
   +++ 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
+  18: [mq]: 6.patch - jane
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   ==== qref -d
   # HG changeset patch
   # Node ID 5702c529dfe926c59f294681367f5ba74efc6c6a
@@ -827,10 +827,10 @@ 
   +++ 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
+  19: [mq]: 6.patch - jane
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   popping 6.patch
   now at: 5.patch
   ==== qnew -d
@@ -845,10 +845,10 @@ 
   +++ 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
+  20: [mq]: 7.patch - test
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   ==== qref -u
   # HG changeset patch
   # User john
@@ -861,10 +861,10 @@ 
   +++ 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
+  21: [mq]: 7.patch - john - 13.00
+  14: [mq]: 5.patch - test - 11.00
+  9: Three (again) - test - 8.00
+  2: [mq]: 1.patch - test - 4.00
   ==== qnew
   adding 8
   # HG changeset patch
@@ -877,11 +877,11 @@ 
   +++ 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
+  23: [mq]: 8.patch - test
+  21: [mq]: 7.patch - john
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   ==== qref -u -d
   # HG changeset patch
   # User john
@@ -894,11 +894,11 @@ 
   +++ 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
+  24: [mq]: 8.patch - john
+  21: [mq]: 7.patch - john
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   popping 8.patch
   now at: 7.patch
   ==== qnew -m
@@ -915,11 +915,11 @@ 
   +++ 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
+  25: Nine - test
+  21: [mq]: 7.patch - john
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   ==== qref -u -d
   # HG changeset patch
   # User john
@@ -934,11 +934,11 @@ 
   +++ 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
+  26: Nine - john
+  21: [mq]: 7.patch - john
+  14: [mq]: 5.patch - test
+  9: Three (again) - test
+  2: [mq]: 1.patch - test
   popping 9.patch
   now at: 7.patch
   ==== qpop -a / qpush -a
@@ -952,8 +952,8 @@ 
   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
+  5: imported patch 7.patch - john - 13.00
+  4: imported patch 5.patch - test - 11.00
+  3: Three (again) - test - 8.00
+  2: imported patch 1.patch - test - 4.00
   $ rm -r sandbox
diff --git a/tests/test-mq-header-from.t b/tests/test-mq-header-from.t
--- a/tests/test-mq-header-from.t
+++ b/tests/test-mq-header-from.t
@@ -150,7 +150,7 @@ 
   +++ b/1
   @@ -0,0 +1,1 @@
   +1
-  0: [mq]: 1.patch - test
+  1: [mq]: 1.patch - test
   ==== qref -u
   From: mary
   Date: 1 0
@@ -160,7 +160,7 @@ 
   +++ b/1
   @@ -0,0 +1,1 @@
   +1
-  0: [mq]: 1.patch - mary
+  2: [mq]: 1.patch - mary
   ==== qnew
   adding 2
   Date: 1 0
@@ -170,8 +170,8 @@ 
   +++ b/2
   @@ -0,0 +1,1 @@
   +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - mary
+  4: [mq]: 2.patch - test
+  2: [mq]: 1.patch - mary
   ==== qref -u
   From: jane
   Date: 1 0
@@ -181,17 +181,17 @@ 
   +++ b/2
   @@ -0,0 +1,1 @@
   +2
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qnew -U -m
   From: test
   Date: 1 0
   
   Three
   
-  2: Three - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  6: Three - test
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref
   adding 3
   From: test
@@ -204,9 +204,9 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  2: Three - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  7: Three - test
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref -m
   From: test
   Date: 1 0
@@ -218,9 +218,9 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  2: Drei - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  8: Drei - test
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref -u
   From: mary
   Date: 1 0
@@ -232,9 +232,9 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  2: Drei - mary
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  9: Drei - mary
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref -u -m
   From: maria
   Date: 1 0
@@ -246,9 +246,9 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qnew -m
   adding 4of
   Date: 1 0
@@ -260,10 +260,10 @@ 
   +++ 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
+  12: Four - test
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref -u
   From: jane
   Date: 1 0
@@ -275,10 +275,10 @@ 
   +++ 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
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qnew with HG header
   popping 5.patch
   now at: 4.patch
@@ -287,11 +287,11 @@ 
   
   # 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
+  14: imported patch 5.patch - johndoe
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref
   adding 5
   Date: 1 0
@@ -305,11 +305,11 @@ 
   +++ 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
+  15: [mq]: 5.patch - johndoe
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref -U
   Date: 1 0
   
@@ -322,11 +322,11 @@ 
   +++ 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
+  16: [mq]: 5.patch - test
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref -u
   Date: 1 0
   
@@ -339,11 +339,11 @@ 
   +++ 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
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qnew with plain header
   popping 6.patch
   now at: 5.patch
@@ -351,12 +351,12 @@ 
   From: test
   Date: 1 0
   
-  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
+  18: imported patch 6.patch - test
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref
   adding 6
   From: test
@@ -367,12 +367,12 @@ 
   +++ 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
+  19: [mq]: 6.patch - test
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref -U
   From: test
   Date: 1 0
@@ -382,12 +382,12 @@ 
   +++ 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
+  19: [mq]: 6.patch - test
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref -u
   From: johndeere
   Date: 1 0
@@ -397,12 +397,12 @@ 
   +++ 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
+  20: [mq]: 6.patch - johndeere
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qpop -a / qpush -a
   popping 6.patch
   popping 5.patch
@@ -418,12 +418,12 @@ 
   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
+  7: imported patch 6.patch - johndeere
+  6: imported patch 5.patch - johndeere
+  5: Four - jane
+  4: Three (again) - maria
+  3: imported patch 2.patch - jane
+  2: imported patch 1.patch - mary
   $ rm -r sandbox
 
 ======= hg headers
@@ -453,7 +453,7 @@ 
   +++ b/1
   @@ -0,0 +1,1 @@
   +1
-  0: [mq]: 1.patch - test
+  1: [mq]: 1.patch - test
   ==== qref -u
   # HG changeset patch
   # Node ID b5fb1b74f7c3f2cc2570cb7df6bb949e5f4ee28d
@@ -466,7 +466,7 @@ 
   +++ b/1
   @@ -0,0 +1,1 @@
   +1
-  0: [mq]: 1.patch - mary
+  2: [mq]: 1.patch - mary
   ==== qnew
   adding 2
   # HG changeset patch
@@ -479,8 +479,8 @@ 
   +++ b/2
   @@ -0,0 +1,1 @@
   +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - mary
+  4: [mq]: 2.patch - test
+  2: [mq]: 1.patch - mary
   ==== qref -u
   # HG changeset patch
   # User jane
@@ -493,8 +493,8 @@ 
   +++ b/2
   @@ -0,0 +1,1 @@
   +2
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qnew -U -m
   # HG changeset patch
   # Node ID 35f253918fbc7af1ceefc27682137dd8e3d4c7e8
@@ -504,9 +504,9 @@ 
   
   Three
   
-  2: Three - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  6: Three - test
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref
   adding 3
   # HG changeset patch
@@ -522,9 +522,9 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  2: Three - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  7: Three - test
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref -m
   # HG changeset patch
   # Node ID 3bbb4f6ec74d70c81c00c4a2b3686fdc8cdf9892
@@ -539,9 +539,9 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  2: Drei - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  8: Drei - test
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref -u
   # HG changeset patch
   # Node ID a94ee07d2f1094eadb3f1f35419f6d564003bac9
@@ -556,9 +556,9 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  2: Drei - mary
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  9: Drei - mary
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref -u -m
   # HG changeset patch
   # Node ID edbb63251a84dd39aeeece909a46eb25756a25ea
@@ -573,9 +573,9 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qnew -m
   adding 4of
   # HG changeset patch
@@ -590,10 +590,10 @@ 
   +++ 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
+  12: Four - test
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref -u
   # HG changeset patch
   # User jane
@@ -608,10 +608,10 @@ 
   +++ 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
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qnew with HG header
   popping 5.patch
   now at: 4.patch
@@ -620,11 +620,11 @@ 
   
   # 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
+  14: imported patch 5.patch - johndoe
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref
   adding 5
   Date: 1 0
@@ -639,11 +639,11 @@ 
   +++ 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
+  15: [mq]: 5.patch - johndoe
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref -U
   Date: 1 0
   
@@ -657,11 +657,11 @@ 
   +++ 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
+  16: [mq]: 5.patch - test
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref -u
   Date: 1 0
   
@@ -675,11 +675,11 @@ 
   +++ 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
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qnew with plain header
   popping 6.patch
   now at: 5.patch
@@ -687,12 +687,12 @@ 
   From: test
   Date: 1 0
   
-  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
+  18: imported patch 6.patch - test
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref
   adding 6
   From: test
@@ -703,12 +703,12 @@ 
   +++ 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
+  19: [mq]: 6.patch - test
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref -U
   From: test
   Date: 1 0
@@ -718,12 +718,12 @@ 
   +++ 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
+  19: [mq]: 6.patch - test
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref -u
   From: johndeere
   Date: 1 0
@@ -733,12 +733,12 @@ 
   +++ 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
+  20: [mq]: 6.patch - johndeere
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qpop -a / qpush -a
   popping 6.patch
   popping 5.patch
@@ -754,12 +754,12 @@ 
   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
+  7: imported patch 6.patch - johndeere
+  6: imported patch 5.patch - johndeere
+  5: Four - jane
+  4: Three (again) - maria
+  3: imported patch 2.patch - jane
+  2: imported patch 1.patch - mary
   $ rm -r sandbox
   $ runtest
   ==== init
@@ -784,7 +784,7 @@ 
   +++ b/1
   @@ -0,0 +1,1 @@
   +1
-  0: [mq]: 1.patch - test
+  1: [mq]: 1.patch - test
   ==== qref -u
   # HG changeset patch
   # Node ID b5fb1b74f7c3f2cc2570cb7df6bb949e5f4ee28d
@@ -797,7 +797,7 @@ 
   +++ b/1
   @@ -0,0 +1,1 @@
   +1
-  0: [mq]: 1.patch - mary
+  2: [mq]: 1.patch - mary
   ==== qnew
   adding 2
   # HG changeset patch
@@ -810,8 +810,8 @@ 
   +++ b/2
   @@ -0,0 +1,1 @@
   +2
-  1: [mq]: 2.patch - test
-  0: [mq]: 1.patch - mary
+  4: [mq]: 2.patch - test
+  2: [mq]: 1.patch - mary
   ==== qref -u
   # HG changeset patch
   # User jane
@@ -824,8 +824,8 @@ 
   +++ b/2
   @@ -0,0 +1,1 @@
   +2
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qnew -U -m
   # HG changeset patch
   # Node ID 35f253918fbc7af1ceefc27682137dd8e3d4c7e8
@@ -835,9 +835,9 @@ 
   
   Three
   
-  2: Three - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  6: Three - test
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref
   adding 3
   # HG changeset patch
@@ -853,9 +853,9 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  2: Three - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  7: Three - test
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref -m
   # HG changeset patch
   # Node ID 3bbb4f6ec74d70c81c00c4a2b3686fdc8cdf9892
@@ -870,9 +870,9 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  2: Drei - test
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  8: Drei - test
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref -u
   # HG changeset patch
   # Node ID a94ee07d2f1094eadb3f1f35419f6d564003bac9
@@ -887,9 +887,9 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  2: Drei - mary
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  9: Drei - mary
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref -u -m
   # HG changeset patch
   # Node ID edbb63251a84dd39aeeece909a46eb25756a25ea
@@ -904,9 +904,9 @@ 
   +++ b/3
   @@ -0,0 +1,1 @@
   +3
-  2: Three (again) - maria
-  1: [mq]: 2.patch - jane
-  0: [mq]: 1.patch - mary
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qnew -m
   adding 4of
   # HG changeset patch
@@ -921,10 +921,10 @@ 
   +++ 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
+  12: Four - test
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qref -u
   # HG changeset patch
   # User jane
@@ -939,10 +939,10 @@ 
   +++ 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
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qnew with HG header
   popping 5.patch
   now at: 4.patch
@@ -951,11 +951,11 @@ 
   
   # 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
+  14: imported patch 5.patch - johndoe
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref
   adding 5
   Date: 1 0
@@ -970,11 +970,11 @@ 
   +++ 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
+  15: [mq]: 5.patch - johndoe
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref -U
   Date: 1 0
   
@@ -988,11 +988,11 @@ 
   +++ 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
+  16: [mq]: 5.patch - test
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref -u
   Date: 1 0
   
@@ -1006,11 +1006,11 @@ 
   +++ 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
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qnew with plain header
   popping 6.patch
   now at: 5.patch
@@ -1018,12 +1018,12 @@ 
   From: test
   Date: 1 0
   
-  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
+  18: imported patch 6.patch - test
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref
   adding 6
   From: test
@@ -1034,12 +1034,12 @@ 
   +++ 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
+  19: [mq]: 6.patch - test
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref -U
   From: test
   Date: 1 0
@@ -1049,12 +1049,12 @@ 
   +++ 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
+  19: [mq]: 6.patch - test
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== hg qref -u
   From: johndeere
   Date: 1 0
@@ -1064,12 +1064,12 @@ 
   +++ 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
+  20: [mq]: 6.patch - johndeere
+  17: [mq]: 5.patch - johndeere
+  13: Four - jane
+  10: Three (again) - maria
+  5: [mq]: 2.patch - jane
+  2: [mq]: 1.patch - mary
   ==== qpop -a / qpush -a
   popping 6.patch
   popping 5.patch
@@ -1085,11 +1085,11 @@ 
   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
+  7: imported patch 6.patch - johndeere
+  6: imported patch 5.patch - johndeere
+  5: Four - jane
+  4: Three (again) - maria
+  3: imported patch 2.patch - jane
+  2: imported patch 1.patch - mary
 
   $ cd ..
diff --git a/tests/test-mq-pull-from-bundle.t b/tests/test-mq-pull-from-bundle.t
--- a/tests/test-mq-pull-from-bundle.t
+++ b/tests/test-mq-pull-from-bundle.t
@@ -67,6 +67,11 @@  Bundle queue:
 Clone base:
 
   $ hg clone base copy
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
   updating to branch default
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cd copy
@@ -107,6 +112,11 @@  Pull queue bundle:
 Clone base again:
 
   $ hg clone base copy2
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
   updating to branch default
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cd copy2
diff --git a/tests/test-mq-qpush-fail.t b/tests/test-mq-qpush-fail.t
--- a/tests/test-mq-qpush-fail.t
+++ b/tests/test-mq-qpush-fail.t
@@ -364,7 +364,7 @@  test qpush --keep-changes
   $ hg qtop
   p2
   $ hg parents --template "{rev} {desc}\n"
-  2 imported patch p2
+  3 imported patch p2
   $ hg st b
   M b
   $ cat b
diff --git a/tests/test-mq-qrefresh-interactive.t b/tests/test-mq-qrefresh-interactive.t
--- a/tests/test-mq-qrefresh-interactive.t
+++ b/tests/test-mq-qrefresh-interactive.t
@@ -212,11 +212,12 @@  partial qrefresh
 After partial qrefresh 'tip'
 
   $ hg tip -p
-  changeset:   1:0738af1a8211
+  changeset:   2:0738af1a8211
   tag:         patch
   tag:         qbase
   tag:         qtip
   tag:         tip
+  parent:      0:1fd39ab63a33
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     [mq]: patch
@@ -298,11 +299,12 @@  qrefresh interactively everything else
 After final qrefresh 'tip'
 
   $ hg tip -p
-  changeset:   1:2c3f66afeed9
+  changeset:   3:2c3f66afeed9
   tag:         patch
   tag:         qbase
   tag:         qtip
   tag:         tip
+  parent:      0:1fd39ab63a33
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     [mq]: patch
diff --git a/tests/test-mq-qrefresh.t b/tests/test-mq-qrefresh.t
--- a/tests/test-mq-qrefresh.t
+++ b/tests/test-mq-qrefresh.t
@@ -530,8 +530,6 @@  but only after writing the bad name into
   $ hg qnew a
   $ hg qrefresh -u 'foo
   > bar'
-  transaction abort!
-  rollback completed
   refresh interrupted while patch was popped! (revert --all, qpush to recover)
   abort: username 'foo\nbar' contains a newline!
   [255]
@@ -545,11 +543,10 @@  but only after writing the bad name into
   diff --git a/a b/a
   new file mode 100644
   $ hg qpush
+  (working directory not at a head)
   applying a
   now at: a
   $ hg qrefresh -u ' '
-  transaction abort!
-  rollback completed
   refresh interrupted while patch was popped! (revert --all, qpush to recover)
   abort: empty username!
   [255]
@@ -575,11 +572,11 @@  Refresh with phase data:
   $ echo 'beber' >> a
   $ hg qref
   $ hg phase p2.diff
-  2: draft
+  3: draft
   $ hg phase --force --secret p2.diff
   $ echo 'bibir' >> a
   $ hg qref
   $ hg phase p2.diff
-  2: secret
+  4: secret
 
   $ cd ..
diff --git a/tests/test-mq-safety.t b/tests/test-mq-safety.t
--- a/tests/test-mq-safety.t
+++ b/tests/test-mq-safety.t
@@ -86,7 +86,7 @@  qpop/qrefresh on the wrong revision
   abort: cannot refresh a revision with children
   [255]
   $ hg tip --template '{rev} {desc}\n'
-  3 append quux
+  5 append quux
 
 
 qpush warning branchheads
diff --git a/tests/test-mq-symlinks.t b/tests/test-mq-symlinks.t
--- a/tests/test-mq-symlinks.t
+++ b/tests/test-mq-symlinks.t
@@ -50,6 +50,7 @@  test updating a symlink
   applying updatelink
   patching file a
   a
+  qpush created 83fbbbeefaa5
   now at: updatelink
   $ "$TESTDIR/readlink.py" a
   a -> c
diff --git a/tests/test-mq.t b/tests/test-mq.t
--- a/tests/test-mq.t
+++ b/tests/test-mq.t
@@ -172,7 +172,7 @@  qinit -c should create both files if the
   $ hg add foo
   $ hg qrefresh
   $ hg phase -r qbase
-  0: draft
+  1: draft
   $ hg qnew B
   $ echo >> foo
   $ hg qrefresh
@@ -329,13 +329,13 @@  Dump the tag cache to ensure that it has
   applying test.patch
   now at: test.patch
   $ hg phase -r qbase
-  2: draft
+  3: draft
   $ hg tags > /dev/null
 
 .hg/cache/tags (post qpush):
 
   $ cat .hg/cache/tags
-  2 [\da-f]{40} (re)
+  3 [\da-f]{40} (re)
   
   $ checkundo qpush
   $ cd ..
@@ -891,9 +891,9 @@  qpush failure
 mq tags
 
   $ hg log -G --template '{rev} {tags}\n' -r qparent:qtip
-  @  2 bar qtip tip
+  @  5 bar qtip tip
   |
-  o  1 foo qbase
+  x  4 foo qbase
   |
   o  0 qparent
   
@@ -901,9 +901,9 @@  mq tags
 mq revset
 
   $ hg log -G -r 'mq()' --template '{rev}\n'
-  @  2
+  @  5
   |
-  o  1
+  x  4
   |
   $ hg help revsets | grep -i mq
       "mq()"
@@ -962,6 +962,8 @@  git patches
   +foo
 #else
   $ cat .hg/patches/new
+  Date: 1 0
+  
   new file
   
   diff --git a/new b/new
@@ -1104,7 +1106,7 @@  test file move chains in the slow path
   @@ -0,0 +1,1 @@
   +bar
   $ hg log -v --template '{rev} {file_copies}\n' -r .
-  3 bleh (foo)
+  5 bleh (foo)
   $ hg mv quux fred
   $ hg mv bleh barney
   $ hg qrefresh --git
@@ -1121,7 +1123,7 @@  test file move chains in the slow path
   @@ -0,0 +1,1 @@
   +bar
   $ hg log -v --template '{rev} {file_copies}\n' -r .
-  3 barney (foo)
+  6 barney (foo)
 
 
 refresh omitting an added file
@@ -1288,7 +1290,7 @@  repo with unversioned patch dir
   $ hg qci -m checkpoint
   $ qlog
   main repo:
-      rev 1: change foo
+      rev 2: change foo
       rev 0: add foo
   patch repo:
       rev 0: checkpoint
@@ -1298,6 +1300,11 @@  repo with unversioned patch dir
 repo with patches applied
 
   $ hg qclone qclonesource qclonedest
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
   updating to branch default
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -1323,6 +1330,11 @@  repo with patches unapplied
       rev 0: checkpoint
   $ cd ..
   $ hg qclone qclonesource qclonedest2
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
   updating to branch default
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -1536,34 +1548,39 @@  Proper phase default with mq:
 1. mq.secret=false
 
   $ hg log -G --hidden -T '{rev}  {tags}  {desc|firstline}\n'
-  @  2  modify-file qtip tip  imported patch modify-file
+  @  3  modify-file qtip tip  imported patch modify-file
   |
-  o  1  add-file2  imported patch add-file2
+  o  2  add-file2  imported patch add-file2
   |
-  o  0  add-file1 qbase  imported patch add-file1
+  o  1  add-file1 qbase  imported patch add-file1
+  
+  x  0    [mq]: add-file1
   
 
   $ rm .hg/store/phaseroots
   $ hg phase 'qparent::'
-  0: draft
+  0: public
   1: draft
   2: draft
+  3: draft
   $ echo '[mq]' >> $HGRCPATH
   $ echo 'secret=true' >> $HGRCPATH
   $ rm -f .hg/store/phaseroots
   $ hg phase 'qparent::'
-  0: secret
+  0: public
   1: secret
   2: secret
+  3: secret
 
 Test that qfinish change phase when mq.secret=true
 
   $ hg qfinish qbase
   patch add-file1 finalized without changeset message
   $ hg phase 'all()'
-  0: draft
-  1: secret
+  0: public
+  1: draft
   2: secret
+  3: secret
 
 Test that qfinish respect phases.new-commit setting
 
@@ -1572,9 +1589,10 @@  Test that qfinish respect phases.new-com
   $ hg qfinish qbase
   patch add-file2 finalized without changeset message
   $ hg phase 'all()'
-  0: draft
-  1: secret
+  0: public
+  1: draft
   2: secret
+  3: secret
 
 (restore env for next test)
 
@@ -1589,9 +1607,10 @@  Test that qfinish preserve phase when mq
   $ hg qfinish qbase
   patch add-file2 finalized without changeset message
   $ hg phase 'all()'
-  0: draft
-  1: secret
+  0: public
+  1: draft
   2: secret
+  3: secret
 
 Test that secret mq patch does not break hgweb
 
diff --git a/tests/test-mq2.t b/tests/test-mq2.t
--- a/tests/test-mq2.t
+++ b/tests/test-mq2.t
@@ -48,9 +48,9 @@ 
   $ hg qnew a2 -m a2 -d '117 0'
 
   $ hg log -G --template "{rev} {node|short} {phase} {desc|firstline}\n"
-  @  2 757e6e08e7eb draft a2
+  @  3 757e6e08e7eb draft a2
   |
-  o  1 3506c28d72aa draft b
+  o  2 3506c28d72aa draft b
   |
   o  0 cb9a9f314b8b draft a
   
@@ -63,7 +63,7 @@ 
   3506c28d72aa3a31f8ce50ca4cfcb812af131450:b
 
   $ hg log -G --template "{rev} {node|short} {phase} {desc|firstline}\n"
-  @  1 3506c28d72aa draft b
+  @  2 3506c28d72aa draft b
   |
   o  0 cb9a9f314b8b draft a
   
@@ -77,9 +77,9 @@ 
   757e6e08e7eb6b956e2d583ff4d7450d392f8a13:a2
 
   $ hg log -G --template "{rev} {node|short} {phase} {desc|firstline}\n"
-  @  2 757e6e08e7eb draft a2
+  @  3 757e6e08e7eb draft a2
   |
-  o  1 3506c28d72aa draft b
+  o  2 3506c28d72aa draft b
   |
   o  0 cb9a9f314b8b draft a
   
@@ -92,7 +92,7 @@ 
   $ hg ci -m yada
 
   $ hg log -G --template "{rev} {node|short} {phase} {desc|firstline}\n"
-  @  1 dfa6dafa9c6c draft yada
+  @  2 dfa6dafa9c6c draft yada
   |
   o  0 cb9a9f314b8b draft a
   
@@ -131,11 +131,11 @@ 
   applying a2
   now at: a2
   $ hg log -G --template "{rev} {node|short} {phase} {desc|firstline}\n"
-  @  3 cd192c2f0104 draft a2
+  @  4 cd192c2f0104 draft a2
   |
-  o  2 c27d00b1f47f draft b
+  o  3 c27d00b1f47f draft b
   |
-  o  1 dfa6dafa9c6c draft yada
+  o  2 dfa6dafa9c6c draft yada
   |
   o  0 cb9a9f314b8b draft a
   
@@ -151,7 +151,7 @@ 
   $ hg qrm a2
 (should also have stripped b that couldn't be stripped before)
   $ hg log -G --template "{rev} {node|short} {phase} {desc|firstline}\n"
-  @  1 dfa6dafa9c6c draft yada
+  @  2 dfa6dafa9c6c draft yada
   |
   o  0 cb9a9f314b8b draft a