comparison hgext/histedit.py @ 27673:d93d340dc6ee

histedit: replace editcomment with a function
author timeless <timeless@mozdev.org>
date Wed, 23 Dec 2015 21:17:45 +0000
parents 9358124b4a65
children 78d86664e3a2
comparison
equal deleted inserted replaced
27672:f2da9bb87ae0 27673:d93d340dc6ee
212 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should 212 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
213 # be specifying the version(s) of Mercurial they are tested with, or 213 # be specifying the version(s) of Mercurial they are tested with, or
214 # leave the attribute unspecified. 214 # leave the attribute unspecified.
215 testedwith = 'internal' 215 testedwith = 'internal'
216 216
217 # i18n: command names and abbreviations must remain untranslated 217 def geteditcomment(first, last):
218 editcomment = _("""# Edit history between %s and %s 218 """ construct the editor comment
219 # 219 The comment includes::
220 # Commits are listed from least to most recent 220 - an intro
221 # 221 - short commands
222 # Commands: 222
223 # p, pick = use commit 223 Commands are only included once.
224 # e, edit = use commit, but stop for amending 224 """
225 # f, fold = use commit, but combine it with the one above 225 intro = _("""Edit history between %s and %s
226 # r, roll = like fold, but discard this commit's description 226
227 # d, drop = remove commit from history 227 Commits are listed from least to most recent
228 # m, mess = edit commit message without changing commit content 228
229 # 229 Commands:""")
230 # i18n: command names and abbreviations must remain untranslated
231 verbs = _("""
232 p, pick = use commit
233 e, edit = use commit, but stop for amending
234 f, fold = use commit, but combine it with the one above
235 r, roll = like fold, but discard this commit's description
236 d, drop = remove commit from history
237 m, mess = edit commit message without changing commit content
230 """) 238 """)
239
240 return ''.join(['# %s\n' % l if l else '#\n'
241 for l in ((intro % (first, last) + verbs).split('\n'))])
231 242
232 class histeditstate(object): 243 class histeditstate(object):
233 def __init__(self, repo, parentctxnode=None, actions=None, keep=None, 244 def __init__(self, repo, parentctxnode=None, actions=None, keep=None,
234 topmost=None, replacements=None, lock=None, wlock=None): 245 topmost=None, replacements=None, lock=None, wlock=None):
235 self.repo = repo 246 self.repo = repo
974 state.read() 985 state.read()
975 state = bootstrapcontinue(ui, state, opts) 986 state = bootstrapcontinue(ui, state, opts)
976 elif goal == 'edit-plan': 987 elif goal == 'edit-plan':
977 state.read() 988 state.read()
978 if not rules: 989 if not rules:
979 comment = editcomment % (node.short(state.parentctxnode), 990 comment = geteditcomment(node.short(state.parentctxnode),
980 node.short(state.topmost)) 991 node.short(state.topmost))
981 rules = ruleeditor(repo, ui, state.actions, comment) 992 rules = ruleeditor(repo, ui, state.actions, comment)
982 else: 993 else:
983 if rules == '-': 994 if rules == '-':
984 f = sys.stdin 995 f = sys.stdin
1057 raise error.Abort(_('%s is not an ancestor of working directory') % 1068 raise error.Abort(_('%s is not an ancestor of working directory') %
1058 node.short(root)) 1069 node.short(root))
1059 1070
1060 ctxs = [repo[r] for r in revs] 1071 ctxs = [repo[r] for r in revs]
1061 if not rules: 1072 if not rules:
1062 comment = editcomment % (node.short(root), node.short(topmost)) 1073 comment = geteditcomment(node.short(root), node.short(topmost))
1063 actions = [pick(state, r) for r in revs] 1074 actions = [pick(state, r) for r in revs]
1064 rules = ruleeditor(repo, ui, actions, comment) 1075 rules = ruleeditor(repo, ui, actions, comment)
1065 else: 1076 else:
1066 if rules == '-': 1077 if rules == '-':
1067 f = sys.stdin 1078 f = sys.stdin