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

login
register
mail settings
Submitter phabricator
Date Feb. 26, 2019, 12:24 p.m.
Message ID <differential-rev-PHID-DREV-xmpix7vfnri6g5zcifbx-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/38938/
State New
Headers show

Comments

phabricator - Feb. 26, 2019, 12:24 p.m.
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




To: navaneeth.suresh, martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - March 6, 2019, 5:45 a.m.
navaneeth.suresh added a comment.


  Ping for review.

REPOSITORY
  rHG Mercurial

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

To: navaneeth.suresh, martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - March 24, 2019, 6:09 p.m.
navaneeth.suresh added a comment.


  Gentle ping for review.

REPOSITORY
  rHG Mercurial

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

To: navaneeth.suresh, martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - March 26, 2019, 6:21 p.m.
navaneeth.suresh added a comment.


  > It doesn't make sense to check the existence of 'shelvedstate' in a static
  >  table.
  > 
  > Can't we somehow get around the mq in a similar way to shelve.getcommitfunc()?
  >  I don't think it's good idea to rely on state files saved on disk.
  
  I felt that the only workaround to stop aborting unshelve on a modified mq patch should be adding a check on `mq.abortifwdirpatched()`. Will try to investigate in `shelve.getcommitfunc()` for sure. Thanks.

REPOSITORY
  rHG Mercurial

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

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

Patch

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: