D6027: mq: make unshelve to apply on modified mq patch (issue4318)

navaneeth.suresh (Navaneeth Suresh) phabricator at mercurial-scm.org
Tue Feb 26 12:24:52 UTC 2019


navaneeth.suresh created this revision.
Herald added a reviewer: martinvonz.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  unshelve wasn't working on a modified mq patch. I added checks for
  not aborting on a modified mq patch in both rebase and mq.
  
  Checking `repo.vfs.exists('unshelverebasestate')` works in rebase,
  not in mq. I used `cmdutil.unfinishedstates` to find `shelvedstate`
  in mq.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6027

AFFECTED FILES
  hgext/mq.py
  hgext/rebase.py
  tests/test-mq.t

CHANGE DETAILS

diff --git a/tests/test-mq.t b/tests/test-mq.t
--- a/tests/test-mq.t
+++ b/tests/test-mq.t
@@ -1619,3 +1619,24 @@
 
 
   $ cd ..
+
+unshelve shoudn't be refusing on modified mq patch
+
+  $ hg init issue4318
+  $ cd issue4318
+  $ echo '[extensions]' >> $HGRCPATH
+  $ echo 'mq =' >> $HGRCPATH
+  $ echo 'shelve =' >> $HGRCPATH
+  $ echo a>a
+  $ hg add a
+  $ hg qnew -ma a.patch
+  $ echo a2>>a
+  $ hg shelve
+  shelved as default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo b>b
+  $ hg add b
+  $ hg qref
+  $ hg unshelve
+  unshelving change 'default'
+  rebasing shelved changes
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1703,7 +1703,8 @@
     # a partially completed rebase is blocked by mq.
     if 'qtip' in repo.tags():
         mqapplied = set(repo[s.node].rev() for s in repo.mq.applied)
-        if set(destmap.values()) & mqapplied:
+        if set(destmap.values()) & mqapplied and \
+            not repo.vfs.exists('unshelverebasestate'):
             raise error.Abort(_('cannot rebase onto an applied mq patch'))
 
     # Get "cycle" error early by exhausting the generator.
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -3518,7 +3518,10 @@
                 delattr(self.unfiltered(), r'mq')
 
         def abortifwdirpatched(self, errmsg, force=False):
-            if self.mq.applied and self.mq.checkapplied and not force:
+            shelveinprogress = any('shelvedstate' in state
+                                    for state in cmdutil.unfinishedstates)
+            if self.mq.applied and self.mq.checkapplied and not force and \
+                not shelveinprogress:
                 parents = self.dirstate.parents()
                 patches = [s.node for s in self.mq.applied]
                 if parents[0] in patches or parents[1] in patches:



To: navaneeth.suresh, martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list