[PATCH 2 of 3] histedit: generalize makedesc
Mateusz Kwapich
mitrandir at fb.com
Mon Feb 23 13:38:24 CST 2015
# HG changeset patch
# User Mateusz Kwapich <mitrandir at fb.com>
# Date 1421952770 28800
# Thu Jan 22 10:52:50 2015 -0800
# Node ID 9ba9c4d96b6770a53012c02beaaf8a7975060478
# Parent 5876af0d2972dbed4e147d7bd1b38a24e6908b10
histedit: generalize makedesc
Allow makedesc to generate description for any action - not only pick.
(to be used in histedit --edit-plan)
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -798,17 +798,18 @@ def between(repo, old, new, keep):
raise util.Abort(_('cannot edit immutable changeset: %s') % root)
return [c.node() for c in ctxs]
-def makedesc(c):
- """build a initial action line for a ctx `c`
+def makedesc(repo, action, rev):
+ """build a initial action line for a ctx
line are in the form:
- pick <hash> <rev> <summary>
+ <action> <hash> <rev> <summary>
"""
+ ctx = repo[rev]
summary = ''
- if c.description():
- summary = c.description().splitlines()[0]
- line = 'pick %s %d %s' % (c, c.rev(), summary)
+ if ctx.description():
+ summary = ctx.description().splitlines()[0]
+ line = '%s %s %d %s' % (action, ctx, ctx.rev(), summary)
# trim to 80 columns so it's not stupidly wide in my editor
return util.ellipsis(line, 80)
@@ -817,7 +818,7 @@ def ruleeditor(repo, ui, rules, editcomm
rules are in the format [ [act, ctx], ...] like in state.rules
"""
- rules = '\n'.join([makedesc(repo[rev]) for [act, rev] in rules])
+ rules = '\n'.join([makedesc(repo, act, rev) for [act, rev] in rules])
rules += '\n\n'
rules += editcomment
rules = ui.edit(rules, ui.username())
More information about the Mercurial-devel
mailing list