diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -361,6 +361,8 @@ def updatemq(repo, state, skipped, **opt '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: @@ -378,6 +380,15 @@ def updatemq(repo, state, skipped, **opt 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, diff --git a/tests/test-rebase-mq.t b/tests/test-rebase-mq.t --- a/tests/test-rebase-mq.t +++ b/tests/test-rebase-mq.t @@ -235,3 +235,73 @@ Rebase the applied mq patches: -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) +