comparison hgext/histedit.py @ 24141:671da7d34804

histedit: generalize makedesc Allow makedesc to generate description for any action - not only pick. (to be used in histedit --edit-plan)
author Mateusz Kwapich <mitrandir@fb.com>
date Thu, 22 Jan 2015 10:52:50 -0800
parents 5a64b676c5d3
children be7cb25186be
comparison
equal deleted inserted replaced
24140:5a64b676c5d3 24141:671da7d34804
803 root = ctxs[0] # list is already sorted by repo.set 803 root = ctxs[0] # list is already sorted by repo.set
804 if not root.mutable(): 804 if not root.mutable():
805 raise util.Abort(_('cannot edit immutable changeset: %s') % root) 805 raise util.Abort(_('cannot edit immutable changeset: %s') % root)
806 return [c.node() for c in ctxs] 806 return [c.node() for c in ctxs]
807 807
808 def makedesc(c): 808 def makedesc(repo, action, rev):
809 """build a initial action line for a ctx `c` 809 """build a initial action line for a ctx
810 810
811 line are in the form: 811 line are in the form:
812 812
813 pick <hash> <rev> <summary> 813 <action> <hash> <rev> <summary>
814 """ 814 """
815 ctx = repo[rev]
815 summary = '' 816 summary = ''
816 if c.description(): 817 if ctx.description():
817 summary = c.description().splitlines()[0] 818 summary = ctx.description().splitlines()[0]
818 line = 'pick %s %d %s' % (c, c.rev(), summary) 819 line = '%s %s %d %s' % (action, ctx, ctx.rev(), summary)
819 # trim to 80 columns so it's not stupidly wide in my editor 820 # trim to 80 columns so it's not stupidly wide in my editor
820 return util.ellipsis(line, 80) 821 return util.ellipsis(line, 80)
821 822
822 def ruleeditor(repo, ui, rules, editcomment=""): 823 def ruleeditor(repo, ui, rules, editcomment=""):
823 """open an editor to edit rules 824 """open an editor to edit rules
824 825
825 rules are in the format [ [act, ctx], ...] like in state.rules 826 rules are in the format [ [act, ctx], ...] like in state.rules
826 """ 827 """
827 rules = '\n'.join([makedesc(repo[rev]) for [act, rev] in rules]) 828 rules = '\n'.join([makedesc(repo, act, rev) for [act, rev] in rules])
828 rules += '\n\n' 829 rules += '\n\n'
829 rules += editcomment 830 rules += editcomment
830 rules = ui.edit(rules, ui.username()) 831 rules = ui.edit(rules, ui.username())
831 832
832 # Save edit rules in .hg/histedit-last-edit.txt in case 833 # Save edit rules in .hg/histedit-last-edit.txt in case