[PATCH 3 of 3 STABLE] mq: check subrepo synchronizations against parent of workdir or other appropriate context

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Jun 21 05:55:17 CDT 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1340275754 -32400
# Branch stable
# Node ID d7d411e74251221b47920bdfbdf9300287021c41
# Parent  b8a0b3a9ca354d42e212ee7e5f025d52e27b9de4
mq: check subrepo synchronizations against parent of workdir or other appropriate context

current implementation 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

diff -r b8a0b3a9ca35 -r d7d411e74251 hgext/mq.py
--- a/hgext/mq.py	Thu Jun 21 19:48:57 2012 +0900
+++ b/hgext/mq.py	Thu Jun 21 19:49:14 2012 +0900
@@ -911,16 +911,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
 
@@ -1445,13 +1449,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:
diff -r b8a0b3a9ca35 -r d7d411e74251 tests/test-mq-subrepo.t
--- a/tests/test-mq-subrepo.t	Thu Jun 21 19:48:57 2012 +0900
+++ b/tests/test-mq-subrepo.t	Thu Jun 21 19:49:14 2012 +0900
@@ -441,4 +441,72 @@
   -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 ..


More information about the Mercurial-devel mailing list