# HG changeset patch # User Mateusz Kwapich # Date 2015-01-22 18:52:50 # Node ID 671da7d3480486bb1cc788dc107438d9c11aa0a5 # Parent 5a64b676c5d3f3a0692b7fa1414e702f7231e133 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 @@ -805,17 +805,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 + """ + 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) @@ -824,7 +825,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())