Patchwork [2,of,5] histedit: replace editcomment with a function

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 23, 2015, 9:10 a.m.
Message ID <43cbe5d791b17d07857e.1450861800@waste.org>
Download mbox | patch
Permalink /patch/12287/
State Superseded
Headers show

Comments

timeless@mozdev.org - Dec. 23, 2015, 9:10 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1450847203 0
#      Wed Dec 23 05:06:43 2015 +0000
# Node ID 43cbe5d791b17d07857ec3791bb7611e737ec6c4
# Parent  9d8cbcdddae979a9e9d188178d28b42a892cce75
histedit: replace editcomment with a function

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -218,13 +218,14 @@ 
 # leave the attribute unspecified.
 testedwith = 'internal'
 
-editcomment = _("""# Edit history between %s and %s
+def editcomment(first, last):
+    preamble = _("""# Edit history between %s and %s
 #
 # Commits are listed from least to most recent
 #
 # Commands:
-%s""") % ("%s", "%s",
-''.join(["#  %s\n" % l for l in (
+%s""")
+    verbs = (
 "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"),
@@ -232,8 +233,10 @@ 
 "d, drop = %s" % _("remove commit from history"),
 "m, mess = %s" % _("edit commit message without changing commit content"),
 "",
-)])
 )
+    verbs = ''.join(["#  %s\n" % l for l in verbs])
+
+    return preamble % (first, last, verbs)
 
 class histeditstate(object):
     def __init__(self, repo, parentctxnode=None, actions=None, keep=None,
@@ -964,7 +967,7 @@ 
     elif goal == 'edit-plan':
         state.read()
         if not rules:
-            comment = editcomment % (node.short(state.parentctxnode),
+            comment = editcomment   (node.short(state.parentctxnode),
                                      node.short(state.topmost))
             rules = ruleeditor(repo, ui, state.actions, comment)
         else:
@@ -1049,7 +1052,7 @@ 
 
         ctxs = [repo[r] for r in revs]
         if not rules:
-            comment = editcomment % (node.short(root), node.short(topmost))
+            comment = editcomment   (node.short(root), node.short(topmost))
             actions = [pick(state, r) for r in revs]
             rules = ruleeditor(repo, ui, actions, comment)
         else: