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

David Soria Parra dsp at experimentalworks.net
Wed Mar 5 16:00:59 CST 2014


Olle Lundberg <olle.lundberg at gmail.com> writes:

> # HG changeset patch
> # User Olle Lundberg <geek at 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.


More information about the Mercurial-devel mailing list