Patchwork [08,of,11,RFC] histedit: modify execute to provide a nicer ui

login
register
mail settings
Submitter Olle Lundberg
Date March 5, 2014, 4:15 p.m.
Message ID <6ffc75ede0d416851eb6.1394036119@SE-C02KQ0DADR55>
Download mbox | patch
Permalink /patch/3859/
State Changes Requested
Headers show

Comments

Olle Lundberg - March 5, 2014, 4:15 p.m.
# HG changeset patch
# User Olle Lundberg <geek@nerd.sh>
# Date 1394035207 -3600
#      Wed Mar 05 17:00:07 2014 +0100
# Node ID 6ffc75ede0d416851eb60ef08f90d50bde803c55
# Parent  fabdf9b14020ff00937114fbc28fc1cb7d99993c
histedit: modify execute to provide a nicer ui

This adds the basic semantics given by a `hg status` before
telling the user to clean up the mess done by the ran command.
David Soria Parra - March 5, 2014, 10 p.m.
Olle Lundberg <olle.lundberg@gmail.com> writes:

> # HG changeset patch
> # User Olle Lundberg <geek@nerd.sh>
> # Date 1394035207 -3600
> #      Wed Mar 05 17:00:07 2014 +0100
> # Node ID 6ffc75ede0d416851eb60ef08f90d50bde803c55
> # Parent  fabdf9b14020ff00937114fbc28fc1cb7d99993c
> histedit: modify execute to provide a nicer ui
>
> This adds the basic semantics given by a `hg status` before
> telling the user to clean up the mess done by the ran command.
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -340,11 +340,25 @@
>      rc = util.system(cmd)
>      if rc != 0:
>          raise error.InterventionRequired(
>              _('Command exited with %i. Fix up the change and run '
>              'hg histedit --continue') % rc)
> -    if util.any(repo.status()[:4]):
> +    states = 'modified added removed deleted'.split()
> +    changestates = zip(states, 'MAR!', repo.status())
> +    fm = ui.formatter('status', opts)
> +    cwd = repo.getcwd()
> +    wcdirty = False
> +    for state, char, files in changestates:
> +        if files:
> +            wcdirty = True
> +            label = 'status.' + state
> +            for f in files:
> +                fm.startitem()
> +                fm.write('status', '%s ', char, label=label)
> +                fm.write('path', '%s\n', repo.pathto(f, cwd), label=label)
> +    fm.end()
> +    if wcdirty:
>          raise error.InterventionRequired(
>              _('Working copy dirty, please check the files listed above.\n'
>                'When you are finished, run hg histedit --continue to resume.'))
>      return ctx, []

Let's just abort like all the other mercurial commands in those
situations and ask the user to run hg status to see which files were
changed. Also we also point the user towards hg <command> --abort in
case we bail, so he knows how to go abort if he is confused.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -340,11 +340,25 @@ 
     rc = util.system(cmd)
     if rc != 0:
         raise error.InterventionRequired(
             _('Command exited with %i. Fix up the change and run '
             'hg histedit --continue') % rc)
-    if util.any(repo.status()[:4]):
+    states = 'modified added removed deleted'.split()
+    changestates = zip(states, 'MAR!', repo.status())
+    fm = ui.formatter('status', opts)
+    cwd = repo.getcwd()
+    wcdirty = False
+    for state, char, files in changestates:
+        if files:
+            wcdirty = True
+            label = 'status.' + state
+            for f in files:
+                fm.startitem()
+                fm.write('status', '%s ', char, label=label)
+                fm.write('path', '%s\n', repo.pathto(f, cwd), label=label)
+    fm.end()
+    if wcdirty:
         raise error.InterventionRequired(
             _('Working copy dirty, please check the files listed above.\n'
               'When you are finished, run hg histedit --continue to resume.'))
     return ctx, []