Patchwork D6551: state: moved cmdutil.afterresolvedstates to statemod

login
register
mail settings
Submitter phabricator
Date June 20, 2019, 6:13 a.m.
Message ID <differential-rev-PHID-DREV-gnrhaboetnlqe6jkoh4p-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/40619/
State Superseded
Headers show

Comments

phabricator - June 20, 2019, 6:13 a.m.
taapas1128 created this revision.
Herald added a reviewer: durin42.
Herald added a reviewer: martinvonz.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This commit moves `cmdutil.afterresolvedstates` and
  adjoining function to `state.py`. The existing users are
  updated accordingly.
  
  Tests remain unchanged.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/histedit.py
  hgext/rebase.py
  hgext/shelve.py
  mercurial/cmdutil.py
  mercurial/state.py

CHANGE DETAILS




To: taapas1128, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - June 27, 2019, 5:02 p.m.
martinvonz added inline comments.

INLINE COMMENTS

> state.py:135
>          self._reportonly = reportonly
> +        self._continueflag = continueflag
>  

I'll move this up two lines in flight so it's consistent with the order above

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6551/new/

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

To: taapas1128, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - June 27, 2019, 5:03 p.m.
martinvonz added inline comments.

INLINE COMMENTS

> martinvonz wrote in state.py:135
> I'll move this up two lines in flight so it's consistent with the order above

Oh, it still won't be consistent... Can you send a follow-up to reorder these assignments to be consistent?

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6551/new/

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

To: taapas1128, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - June 27, 2019, 7:39 p.m.
taapas1128 added inline comments.

INLINE COMMENTS

> martinvonz wrote in state.py:135
> Oh, it still won't be consistent... Can you send a follow-up to reorder these assignments to be consistent?

sure.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6551/new/

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

To: taapas1128, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - June 27, 2019, 9:49 p.m.
taapas1128 added inline comments.

INLINE COMMENTS

> taapas1128 wrote in state.py:135
> sure.

resolved in D6583 <https://phab.mercurial-scm.org/D6583>

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6551/new/

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

To: taapas1128, durin42, martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - July 4, 2019, 3 p.m.
av6 added inline comments.

INLINE COMMENTS

> cmdutil.py:3303
>  
>      afterresolvedstates tuples define a .hg/{file} and the corresponding
>      command needed to finish it.

Now that afterresolvedstates has been removed, you need to update this docstring.

> cmdutil.py:3322
>  
>      If there's a matching afterresolvedstates, howtocontinue will yield
>      repo.ui.warn as the reporter.

Here too.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6551/new/

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

To: taapas1128, durin42, martinvonz, #hg-reviewers
Cc: av6, mercurial-devel

Patch

diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -252,3 +252,26 @@ 
             continue
         if state.isunfinished(repo):
             return (state._opname, state.statusmsg())
+
+afterresolvedstates = [
+    ('graftstate',
+     _('hg graft --continue')),
+    ]
+
+def howtocontinue(repo):
+    '''Check for an unfinished operation and return the command to finish
+    it.
+
+    afterresolvedstates tuples define a .hg/{file} and the corresponding
+    command needed to finish it.
+
+    Returns a (msg, warning) tuple. 'msg' is a string and 'warning' is
+    a boolean.
+    '''
+    contmsg = _("continue: %s")
+    for f, msg in afterresolvedstates:
+        if repo.vfs.exists(f):
+            return contmsg % msg, True
+    if repo[None].dirty(missing=True, merge=False, branch=False):
+        return contmsg % _("hg commit"), False
+    return None, None
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3258,29 +3258,6 @@ 
 #  - (desturl,   destbranch,   destpeer,   outgoing)
 summaryremotehooks = util.hooks()
 
-afterresolvedstates = [
-    ('graftstate',
-     _('hg graft --continue')),
-    ]
-
-def howtocontinue(repo):
-    '''Check for an unfinished operation and return the command to finish
-    it.
-
-    afterresolvedstates tuples define a .hg/{file} and the corresponding
-    command needed to finish it.
-
-    Returns a (msg, warning) tuple. 'msg' is a string and 'warning' is
-    a boolean.
-    '''
-    contmsg = _("continue: %s")
-    for f, msg in afterresolvedstates:
-        if repo.vfs.exists(f):
-            return contmsg % msg, True
-    if repo[None].dirty(missing=True, merge=False, branch=False):
-        return contmsg % _("hg commit"), False
-    return None, None
-
 def checkafterresolved(repo):
     '''Inform the user about the next action after completing hg resolve
 
@@ -3289,7 +3266,7 @@ 
 
     Otherwise, it will yield repo.ui.note.
     '''
-    msg, warning = howtocontinue(repo)
+    msg, warning = statemod.howtocontinue(repo)
     if msg is not None:
         if warning:
             repo.ui.warn("%s\n" % msg)
@@ -3305,7 +3282,7 @@ 
     If there's no task (repo.ui.note for 'hg commit'), it does not offer
     a hint.
     '''
-    after = howtocontinue(repo)
+    after = statemod.howtocontinue(repo)
     hint = None
     if after[1]:
         hint = after[0]
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -1142,5 +1142,5 @@ 
         'unshelve', fname=shelvedstate._filename,
         cmdmsg=_('unshelve already in progress')
     )
-    cmdutil.afterresolvedstates.append(
+    statemod.afterresolvedstates.append(
         [shelvedstate._filename, _('hg unshelve --continue')])
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1951,5 +1951,5 @@ 
                      _("specify merge tool for rebase")))
     cmdutil.summaryhooks.add('rebase', summaryhook)
     statemod.addunfinished('rebase', fname='rebasestate', stopflag=True)
-    cmdutil.afterresolvedstates.append(
+    statemod.afterresolvedstates.append(
         ['rebasestate', _('hg rebase --continue')])
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -2314,5 +2314,5 @@ 
 def extsetup(ui):
     cmdutil.summaryhooks.add('histedit', summaryhook)
     statemod.addunfinished('histedit', fname='histedit-state', allowcommit=True)
-    cmdutil.afterresolvedstates.append(
+    statemod.afterresolvedstates.append(
         ['histedit-state', _('hg histedit --continue')])