Patchwork [2,of,5] resolve: suggest the next action

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 24, 2015, 9:03 p.m.
Message ID <b37f41464819f05f3708.1450990985@waste.org>
Download mbox | patch
Permalink /patch/12347/
State Accepted
Headers show

Comments

timeless@mozdev.org - Dec. 24, 2015, 9:03 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1450985144 0
#      Thu Dec 24 19:25:44 2015 +0000
# Node ID b37f41464819f05f3708e80eefe91fa9fb52f536
# Parent  99bb0f0a91660f1ec6aa355221c64e6349a1836a
resolve: suggest the next action

Expose afterresolvedstates to allow graft and similar to
suggest a message when resolving results in no unresolved
files.

If there isn't a matching state in afterresolvedstates,
then if verbose, suggest commiting.
Gregory Szorc - Dec. 26, 2015, 6:12 p.m.
> On Dec 24, 2015, at 14:03, timeless <timeless@mozdev.org> wrote:
> 
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1450985144 0
> #      Thu Dec 24 19:25:44 2015 +0000
> # Node ID b37f41464819f05f3708e80eefe91fa9fb52f536
> # Parent  99bb0f0a91660f1ec6aa355221c64e6349a1836a
> resolve: suggest the next action
> 
> Expose afterresolvedstates to allow graft and similar to
> suggest a message when resolving results in no unresolved
> files.

I like what this series is doing!

There has been talk (and perhaps even a wiki *Plan page) to implement "hg continue" (and presumably "hg abort") which is an automagical "continue interrupted operation" command. I think this series gets us one step closer, so I don't see it being incompatible with "hg continue" unless there is a concern over output consistency.

> 
> If there isn't a matching state in afterresolvedstates,
> then if verbose, suggest commiting.
> 
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -3361,6 +3361,17 @@
>         if clearable and repo.vfs.exists(f):
>             util.unlink(repo.join(f))
> 
> +afterresolvedstates = [
> +    ]
> +
> +def checkafterresolved(repo):
> +    contmsg = _("continue: %s\n")
> +    for f, msg in afterresolvedstates:
> +        if repo.vfs.exists(f):
> +            repo.ui.warn(contmsg % msg)
> +            return
> +    repo.ui.note(contmsg % _("hg commit"))
> +
> class dirstateguard(object):
>     '''Restore dirstate at unexpected failure.
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -6010,6 +6010,7 @@
>     driverresolvedf = list(ms.driverresolved())
>     if not unresolvedf and not driverresolvedf:
>         ui.status(_('(no more unresolved files)\n'))
> +        cmdutil.checkafterresolved(repo)
>     elif not unresolvedf:
>         ui.status(_('(no more unresolved files -- '
>                     'run "hg resolve --all" to conclude)\n'))
> diff --git a/tests/test-backout.t b/tests/test-backout.t
> --- a/tests/test-backout.t
> +++ b/tests/test-backout.t
> @@ -714,6 +714,7 @@
>   my foo@b71750c4b0fd+ other foo@a30dd8addae3 ancestor foo@913609522437
>    premerge successful
>   (no more unresolved files)
> +  continue: hg commit
>   $ hg status
>   M foo
>   ? foo.orig
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -3361,6 +3361,17 @@ 
         if clearable and repo.vfs.exists(f):
             util.unlink(repo.join(f))
 
+afterresolvedstates = [
+    ]
+
+def checkafterresolved(repo):
+    contmsg = _("continue: %s\n")
+    for f, msg in afterresolvedstates:
+        if repo.vfs.exists(f):
+            repo.ui.warn(contmsg % msg)
+            return
+    repo.ui.note(contmsg % _("hg commit"))
+
 class dirstateguard(object):
     '''Restore dirstate at unexpected failure.
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6010,6 +6010,7 @@ 
     driverresolvedf = list(ms.driverresolved())
     if not unresolvedf and not driverresolvedf:
         ui.status(_('(no more unresolved files)\n'))
+        cmdutil.checkafterresolved(repo)
     elif not unresolvedf:
         ui.status(_('(no more unresolved files -- '
                     'run "hg resolve --all" to conclude)\n'))
diff --git a/tests/test-backout.t b/tests/test-backout.t
--- a/tests/test-backout.t
+++ b/tests/test-backout.t
@@ -714,6 +714,7 @@ 
   my foo@b71750c4b0fd+ other foo@a30dd8addae3 ancestor foo@913609522437
    premerge successful
   (no more unresolved files)
+  continue: hg commit
   $ hg status
   M foo
   ? foo.orig