mq: check subrepo synchronizations against parent of workdir or other appropriate context
Before this patch, MQ checks each subrepo synchronizations against the
working directory context, so ".hgsubstate" updating is not imported
into MQ revision correctly in cases below:
- qrefresh when current ".hgsubstate" is already synchronized with
each subrepos: you can reproduce this easily by just twice or more
qrefresh invocations
- qnew just after rollback of commit which updates ".hgsubstate"
This patch resolves this by checking subrepo states against:
- the parent of "qtop" for qrefresh, or
- the parent of working context otherwise
--- a/hgext/mq.py Wed Jun 27 22:03:27 2012 +0900
+++ b/hgext/mq.py Wed Jun 27 22:03:27 2012 +0900
@@ -933,16 +933,20 @@
return top, patch
return None, None
- def checksubstate(self, repo):
+ def checksubstate(self, repo, baserev=None):
'''return list of subrepos at a different revision than substate.
Abort if any subrepos have uncommitted changes.'''
inclsubs = []
wctx = repo[None]
+ if baserev:
+ bctx = repo[baserev]
+ else:
+ bctx = wctx.parents()[0]
for s in wctx.substate:
if wctx.sub(s).dirty(True):
raise util.Abort(
_("uncommitted changes in subrepository %s") % s)
- elif wctx.sub(s).dirty():
+ elif s not in bctx.substate or bctx.sub(s).dirty():
inclsubs.append(s)
return inclsubs
@@ -1488,13 +1492,14 @@
raise util.Abort(_("cannot refresh immutable revision"),
hint=_('see "hg help phases" for details'))
- inclsubs = self.checksubstate(repo)
+ cparents = repo.changelog.parents(top)
+ patchparent = self.qparents(repo, top)
+
+ inclsubs = self.checksubstate(repo, hex(patchparent))
if inclsubs:
inclsubs.append('.hgsubstate')
substatestate = repo.dirstate['.hgsubstate']
- cparents = repo.changelog.parents(top)
- patchparent = self.qparents(repo, top)
ph = patchheader(self.join(patchfn), self.plainmode)
diffopts = self.diffopts({'git': opts.get('git')}, patchfn)
if msg:
--- a/tests/test-mq-subrepo.t Wed Jun 27 22:03:27 2012 +0900
+++ b/tests/test-mq-subrepo.t Wed Jun 27 22:03:27 2012 +0900
@@ -441,6 +441,74 @@
-b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
+88ac1bef5ed43b689d1d200b59886b675dec474b sub
+ $ hg qrefresh -u test -d '0 0'
+ $ cat .hgsubstate
+ 88ac1bef5ed43b689d1d200b59886b675dec474b sub
+ $ hg diff -c tip
+ diff -r 44f846335325 -r b3e8c5fa3aaa .hgsubstate
+ --- a/.hgsubstate
+ +++ b/.hgsubstate
+ @@ -1,1 +1,1 @@
+ -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
+ +88ac1bef5ed43b689d1d200b59886b675dec474b sub
+ $ cat .hg/patches/import-at-qrefresh
+ # HG changeset patch
+ # Date 0 0
+ # User test
+ # Parent 44f846335325209be6be35dc2c9a4be107278c09
+
+ diff -r 44f846335325 .hgsubstate
+ --- a/.hgsubstate
+ +++ b/.hgsubstate
+ @@ -1,1 +1,1 @@
+ -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
+ +88ac1bef5ed43b689d1d200b59886b675dec474b sub
+
+ $ hg update -C tip
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg qpop -a
+ popping import-at-qrefresh
+ popping import-at-qnew
+ patch queue now empty
+
+ $ hg -R sub update -C 0
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ $ echo 'sub = sub' > .hgsub
+ $ hg commit -Am '#1 in parent'
+ adding .hgsub
+ $ hg -R sub update -C 1
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg commit -Am '#2 in parent (but be rollbacked soon)'
+ $ hg rollback
+ repository tip rolled back to revision 1 (undo commit)
+ working directory now based on revision 1
+ $ hg status
+ M .hgsubstate
+ $ hg qnew -u test -d '0 0' checkstate-at-qnew
+ $ hg -R sub parents --template '{node} sub\n'
+ 88ac1bef5ed43b689d1d200b59886b675dec474b sub
+ $ cat .hgsubstate
+ 88ac1bef5ed43b689d1d200b59886b675dec474b sub
+ $ hg diff -c tip
+ diff -r 4d91eb2fa1d1 -r 1259c112d884 .hgsubstate
+ --- a/.hgsubstate
+ +++ b/.hgsubstate
+ @@ -1,1 +1,1 @@
+ -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
+ +88ac1bef5ed43b689d1d200b59886b675dec474b sub
+ $ cat .hg/patches/checkstate-at-qnew
+ # HG changeset patch
+ # Parent 4d91eb2fa1d1b22ec513347b9cd06f6b49d470fa
+ # User test
+ # Date 0 0
+
+ diff -r 4d91eb2fa1d1 -r 1259c112d884 .hgsubstate
+ --- a/.hgsubstate
+ +++ b/.hgsubstate
+ @@ -1,1 +1,1 @@
+ -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
+ +88ac1bef5ed43b689d1d200b59886b675dec474b sub
+
$ cd ..
$ cd ..