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

login
register
mail settings
Submitter phabricator
Date March 8, 2019, 6:26 p.m.
Message ID <e8e5db55fd222bd5a2fd5bea7ecb9df5@localhost.localdomain>
Download mbox | patch
Permalink /patch/39142/
State Not Applicable
Headers show

Comments

phabricator - March 8, 2019, 6:26 p.m.
navaneeth.suresh updated this revision to Diff 14400.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6027?vs=14245&id=14400

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
Yuya Nishihara - March 25, 2019, 10:24 p.m.
> --- 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):

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.
phabricator - March 25, 2019, 10:29 p.m.
yuja added a comment.


  >   - 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):
  
  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.

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 shouldn'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: