Patchwork [1,of,5,v2] histedit: refactor command names

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 23, 2015, 10:43 p.m.
Message ID <84a11cb9e89d231f298e.1450910590@waste.org>
Download mbox | patch
Permalink /patch/12330/
State Changes Requested
Delegated to: Augie Fackler
Headers show

Comments

timeless@mozdev.org - Dec. 23, 2015, 10:43 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1450828622 0
#      Tue Dec 22 23:57:02 2015 +0000
# Node ID 84a11cb9e89d231f298ec87cad2c3e5b963aec28
# Parent  e2aa9c4030c4109e5efa50462ffc6048ca30106f
histedit: refactor command names

Future patches will actually include additional commands into this list
Augie Fackler - Jan. 5, 2016, 4:44 p.m.
On Wed, Dec 23, 2015 at 04:43:10PM -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@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@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

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,