[PATCH 1 of 5 v2] histedit: refactor command names
Augie Fackler
raf at durin42.com
Tue Jan 5 16:44:02 UTC 2016
On Wed, Dec 23, 2015 at 04:43:10PM -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1450828622 0
> # Tue Dec 22 23:57:02 2015 +0000
> # Node ID 84a11cb9e89d231f298ec87cad2c3e5b963aec28
> # Parent e2aa9c4030c4109e5efa50462ffc6048ca30106f
> histedit: refactor command names
I like where this series is going, but I'd rather take a slightly more
extensible approach (this will make adding new rules, either internal
to hg or as an extension, much easier.) What I have in mind is a class
decorator like this:
@action(['p', 'pick'], _('use commit'), priority=True)
class pick...
@action(['d', 'drop'], _('remove commit from history'))
class drop...
Does that make sense? The decorator builds up the list, inserting
things in a reasonable order (based on priority=True or not), and then
geteditcomment() builds the comment from that list. The bonus here is
that third-party folks with custom actions can then use our decorator,
and can reorder the list to rearrange actions (or, I suppose, hide
actions they deem unfit for their organization.)
Can I convince you to reroll this series that way?
>
> Future patches will actually include additional commands into this list
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -218,20 +218,22 @@
> # leave the attribute unspecified.
> testedwith = 'internal'
>
> -# i18n: command names and abbreviations must remain untranslated
> editcomment = _("""# Edit history between %s and %s
> #
> # Commits are listed from least to most recent
> #
> # Commands:
> -# p, pick = use commit
> -# e, edit = use commit, but stop for amending
> -# f, fold = use commit, but combine it with the one above
> -# r, roll = like fold, but discard this commit's description
> -# d, drop = remove commit from history
> -# m, mess = edit commit message without changing commit content
> -#
> -""")
> +%s""") % ("%s", "%s",
> +''.join(["# %s\n" % l for l in (
> +"p, pick = %s" % _("use commit"),
> +"e, edit = %s" % _("use commit, but stop for amending"),
> +"f, fold = %s" % _("use commit, but combine it with the one above"),
> +"r, roll = %s" % _("like fold, but discard this commit's description"),
> +"d, drop = %s" % _("remove commit from history"),
> +"m, mess = %s" % _("edit commit message without changing commit content"),
> +"",
> +)])
> +)
>
> class histeditstate(object):
> def __init__(self, repo, parentctxnode=None, actions=None, keep=None,
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list