Mercurial > hg
comparison hgext/histedit.py @ 27204:6b77e749af4a
histedit: use torule instead of makedesc in ruleeditor
author | Mateusz Kwapich <mitrandir@fb.com> |
---|---|
date | Wed, 02 Dec 2015 12:19:01 -0800 |
parents | b6a0f0895a25 |
children | 787d8cc3f04e |
comparison
equal
deleted
inserted
replaced
27203:b6a0f0895a25 | 27204:6b77e749af4a |
---|---|
937 elif goal == 'edit-plan': | 937 elif goal == 'edit-plan': |
938 state.read() | 938 state.read() |
939 if not rules: | 939 if not rules: |
940 comment = editcomment % (node.short(state.parentctxnode), | 940 comment = editcomment % (node.short(state.parentctxnode), |
941 node.short(state.topmost)) | 941 node.short(state.topmost)) |
942 rules = ruleeditor(repo, ui, state.rules, comment) | 942 rules = ruleeditor(repo, ui, state.actions, comment) |
943 else: | 943 else: |
944 if rules == '-': | 944 if rules == '-': |
945 f = sys.stdin | 945 f = sys.stdin |
946 else: | 946 else: |
947 f = open(rules) | 947 f = open(rules) |
1020 node.short(root)) | 1020 node.short(root)) |
1021 | 1021 |
1022 ctxs = [repo[r] for r in revs] | 1022 ctxs = [repo[r] for r in revs] |
1023 if not rules: | 1023 if not rules: |
1024 comment = editcomment % (node.short(root), node.short(topmost)) | 1024 comment = editcomment % (node.short(root), node.short(topmost)) |
1025 rules = ruleeditor(repo, ui, [['pick', c] for c in ctxs], comment) | 1025 actions = [pick(state, r) for r in revs] |
1026 rules = ruleeditor(repo, ui, actions, comment) | |
1026 else: | 1027 else: |
1027 if rules == '-': | 1028 if rules == '-': |
1028 f = sys.stdin | 1029 f = sys.stdin |
1029 else: | 1030 else: |
1030 f = open(rules) | 1031 f = open(rules) |
1159 # trim to 80 columns so it's not stupidly wide in my editor | 1160 # trim to 80 columns so it's not stupidly wide in my editor |
1160 maxlen = repo.ui.configint('histedit', 'linelen', default=80) | 1161 maxlen = repo.ui.configint('histedit', 'linelen', default=80) |
1161 maxlen = max(maxlen, 22) # avoid truncating hash | 1162 maxlen = max(maxlen, 22) # avoid truncating hash |
1162 return util.ellipsis(line, maxlen) | 1163 return util.ellipsis(line, maxlen) |
1163 | 1164 |
1164 def ruleeditor(repo, ui, rules, editcomment=""): | 1165 def ruleeditor(repo, ui, actions, editcomment=""): |
1165 """open an editor to edit rules | 1166 """open an editor to edit rules |
1166 | 1167 |
1167 rules are in the format [ [act, ctx], ...] like in state.rules | 1168 rules are in the format [ [act, ctx], ...] like in state.rules |
1168 """ | 1169 """ |
1169 rules = '\n'.join([makedesc(repo, act, rev) for [act, rev] in rules]) | 1170 rules = '\n'.join([act.torule() for act in actions]) |
1170 rules += '\n\n' | 1171 rules += '\n\n' |
1171 rules += editcomment | 1172 rules += editcomment |
1172 rules = ui.edit(rules, ui.username(), {'prefix': 'histedit'}) | 1173 rules = ui.edit(rules, ui.username(), {'prefix': 'histedit'}) |
1173 | 1174 |
1174 # Save edit rules in .hg/histedit-last-edit.txt in case | 1175 # Save edit rules in .hg/histedit-last-edit.txt in case |