Patchwork [5,of,9] histedit: use torule instead of makedesc in ruleeditor

login
register
mail settings
Submitter Mateusz Kwapich
Date Dec. 2, 2015, 8:22 p.m.
Message ID <757f3974870e4be3861c.1449087777@mitrandir-mbp1.local>
Download mbox | patch
Permalink /patch/11769/
State Accepted
Headers show

Comments

Mateusz Kwapich - Dec. 2, 2015, 8:22 p.m.
# HG changeset patch
# User Mateusz Kwapich <mitrandir@fb.com>
# Date 1449087541 28800
#      Wed Dec 02 12:19:01 2015 -0800
# Node ID 757f3974870e4be3861c4a220fd79385bde59414
# Parent  5fbe77bc94ddd267a65b9a5f4563cf7845053ad0
histedit: use torule instead of makedesc in ruleeditor

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -939,7 +939,7 @@ 
         if not rules:
             comment = editcomment % (node.short(state.parentctxnode),
                                      node.short(state.topmost))
-            rules = ruleeditor(repo, ui, state.rules, comment)
+            rules = ruleeditor(repo, ui, state.actions, comment)
         else:
             if rules == '-':
                 f = sys.stdin
@@ -1022,7 +1022,8 @@ 
         ctxs = [repo[r] for r in revs]
         if not rules:
             comment = editcomment % (node.short(root), node.short(topmost))
-            rules = ruleeditor(repo, ui, [['pick', c] for c in ctxs], comment)
+            actions = [pick(state, r) for r in revs]
+            rules = ruleeditor(repo, ui, actions, comment)
         else:
             if rules == '-':
                 f = sys.stdin
@@ -1161,12 +1162,12 @@ 
     maxlen = max(maxlen, 22) # avoid truncating hash
     return util.ellipsis(line, maxlen)
 
-def ruleeditor(repo, ui, rules, editcomment=""):
+def ruleeditor(repo, ui, actions, editcomment=""):
     """open an editor to edit rules
 
     rules are in the format [ [act, ctx], ...] like in state.rules
     """
-    rules = '\n'.join([makedesc(repo, act, rev) for [act, rev] in rules])
+    rules = '\n'.join([act.torule() for act in actions])
     rules += '\n\n'
     rules += editcomment
     rules = ui.edit(rules, ui.username(), {'prefix': 'histedit'})