[PATCH 2 of 4 evolve-ext] fold: add --message and --logfile options

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Apr 14 15:25:27 UTC 2014



On 04/11/2014 10:02 PM, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh at octave.org>
> # Date 1397160122 14400
> #      Thu Apr 10 16:02:02 2014 -0400
> # Branch stable
> # Node ID e7b0d54215c1e539d79f86dd2c518d2407087958
> # Parent  c5b806b24aadeb64ff32476b850d521f0bc37bef
> fold: add --message and --logfile options
>
> This uses cmdutil.logmessage to match common usage for `hg commit`.
>
> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -696,14 +696,9 @@
>                                             copied=copied.get(path))
>                   return mctx
>               raise IOError()
> -        if commitopts.get('message') and commitopts.get('logfile'):
> -            raise util.Abort(_('options --message and --logfile are mutually'
> -                               ' exclusive'))
> -        if commitopts.get('logfile'):
> -            message= open(commitopts['logfile']).read()
> -        elif commitopts.get('message'):
> -            message = commitopts['message']
> -        else:
> +
> +        message = cmdutil.logmessage(repo.ui, commitopts)
> +        if not message:

Wait, it looks like we already had such support, don't we?

>               message = old.description()
>
>           user = commitopts.get('user') or old.user()
> @@ -1722,7 +1717,7 @@
>
>   @command('^fold',
>       [('r', 'rev', [], _("explicitly specify the full set of revision to fold")),
> -    ] + commitopts2,
> +    ] + commitopts + commitopts2,
>       # allow to choose the seed ?
>       _('rev'))
>   def fold(ui, repo, *revs, **opts):
> @@ -1766,11 +1761,16 @@
>               commitopts = opts.copy()
>               allctx = [repo[r] for r in revs]
>               targetphase = max(c.phase() for c in allctx)
> -            msgs = ["HG: This is a fold of %d changesets." % len(allctx)]
> -            msgs += ["HG: Commit message of changeset %s.\n\n%s\n" %
> -                     (c.rev(), c.description()) for c in allctx]
> -            commitopts['message'] = "\n".join(msgs)
> -            commitopts['edit'] = True
> +
> +            if commitopts.get('message') or commitopts.get('logfile'):
> +                commitopts['edit'] = False
> +            else:
> +                msgs = ["HG: This is a fold of %d changesets." % len(allctx)]
> +                msgs += ["HG: Commit message of changeset %s.\n\n%s\n" %
> +                         (c.rev(), c.description()) for c in allctx]
> +                commitopts['message'] =  "\n".join(msgs)
> +                commitopts['edit'] = True
> +

I'm not sure what this is about. Can you update the changeset 
description to cover it?

Thanks for looking at this.

-- 
Pierre-Yves



More information about the Mercurial-devel mailing list