rebase: restore mq guards after rebasing (
issue2107)
Guards on rebased mq patches were lost.
This patch restores them after the qimporting step.
--- a/hgext/rebase.py Wed Mar 16 23:09:14 2011 +0100
+++ b/hgext/rebase.py Sat Mar 26 13:05:17 2011 +0100
@@ -354,6 +354,8 @@
'Update rebased mq patches - finalize and then import them'
mqrebase = {}
mq = repo.mq
+ original_series = mq.full_series[:]
+
for p in mq.applied:
rev = repo[p.node].rev()
if rev in state:
@@ -371,6 +373,15 @@
repo.ui.debug('import mq patch %d (%s)\n' % (state[rev], name))
mq.qimport(repo, (), patchname=name, git=isgit,
rev=[str(state[rev])])
+
+ # Restore missing guards
+ for s in original_series:
+ pname = mq.guard_re.split(s, 1)[0]
+ if pname in mq.full_series:
+ repo.ui.debug('restoring guard for patch %s' % (pname))
+ mq.full_series.remove(pname)
+ mq.full_series.append(s)
+ mq.series_dirty = True
mq.save_dirty()
def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches,
--- a/tests/test-rebase-mq.t Wed Mar 16 23:09:14 2011 +0100
+++ b/tests/test-rebase-mq.t Sat Mar 26 13:05:17 2011 +0100
@@ -235,3 +235,73 @@
-mq1
+mq2
+
+Rebase with guards
+
+ $ hg init foo
+ $ cd foo
+ $ echo a > a
+ $ hg ci -Am a
+ adding a
+
+Create mq repo with guarded patches foo and bar:
+
+ $ hg qinit
+ $ hg qnew foo
+ $ hg qguard foo +baz
+ $ echo foo > foo
+ $ hg qref
+ $ hg qpop
+ popping foo
+ patch queue now empty
+
+ $ hg qnew bar
+ $ hg qguard bar +baz
+ $ echo bar > bar
+ $ hg qref
+
+ $ hg qguard -l
+ bar: +baz
+ foo: +baz
+
+ $ hg tglog
+ @ 1:* '[mq]: bar' tags: bar qbase qtip tip (glob)
+ |
+ o 0:* 'a' tags: qparent (glob)
+
+Create new head to rebase bar onto:
+
+ $ hg up -C 0
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ echo b > b
+ $ hg add b
+ $ hg ci -m b
+ created new head
+ $ hg up -C 1
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ $ echo a >> a
+ $ hg qref
+
+ $ hg tglog
+ @ 2:* '[mq]: bar' tags: bar qbase qtip tip (glob)
+ |
+ | o 1:* 'b' tags: (glob)
+ |/
+ o 0:* 'a' tags: qparent (glob)
+
+
+Rebase bar:
+
+ $ hg -q rebase -d 1
+
+ $ hg qguard -l
+ foo: +baz
+ bar: +baz
+
+ $ hg tglog
+ @ 2:* '[mq]: bar' tags: bar qbase qtip tip (glob)
+ |
+ o 1:* 'b' tags: qparent (glob)
+ |
+ o 0:* 'a' tags: (glob)
+