245 command = registrar.command(cmdtable) |
245 command = registrar.command(cmdtable) |
246 |
246 |
247 configtable = {} |
247 configtable = {} |
248 configitem = registrar.configitem(configtable) |
248 configitem = registrar.configitem(configtable) |
249 configitem( |
249 configitem( |
250 b'experimental', b'histedit.autoverb', default=False, |
250 b'experimental', |
|
251 b'histedit.autoverb', |
|
252 default=False, |
251 ) |
253 ) |
252 configitem( |
254 configitem( |
253 b'histedit', b'defaultrev', default=None, |
255 b'histedit', |
|
256 b'defaultrev', |
|
257 default=None, |
254 ) |
258 ) |
255 configitem( |
259 configitem( |
256 b'histedit', b'dropmissing', default=False, |
260 b'histedit', |
|
261 b'dropmissing', |
|
262 default=False, |
257 ) |
263 ) |
258 configitem( |
264 configitem( |
259 b'histedit', b'linelen', default=80, |
265 b'histedit', |
|
266 b'linelen', |
|
267 default=80, |
260 ) |
268 ) |
261 configitem( |
269 configitem( |
262 b'histedit', b'singletransaction', default=False, |
270 b'histedit', |
|
271 b'singletransaction', |
|
272 default=False, |
263 ) |
273 ) |
264 configitem( |
274 configitem( |
265 b'ui', b'interface.histedit', default=None, |
275 b'ui', |
|
276 b'interface.histedit', |
|
277 default=None, |
266 ) |
278 ) |
267 configitem(b'histedit', b'summary-template', default=b'{rev} {desc|firstline}') |
279 configitem(b'histedit', b'summary-template', default=b'{rev} {desc|firstline}') |
268 |
280 |
269 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
281 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
270 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
282 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
278 tertiaryactions = set() |
290 tertiaryactions = set() |
279 internalactions = set() |
291 internalactions = set() |
280 |
292 |
281 |
293 |
282 def geteditcomment(ui, first, last): |
294 def geteditcomment(ui, first, last): |
283 """ construct the editor comment |
295 """construct the editor comment |
284 The comment includes:: |
296 The comment includes:: |
285 - an intro |
297 - an intro |
286 - sorted primary commands |
298 - sorted primary commands |
287 - sorted short commands |
299 - sorted short commands |
288 - sorted long commands |
300 - sorted long commands |
475 self.repo = state.repo |
487 self.repo = state.repo |
476 self.node = node |
488 self.node = node |
477 |
489 |
478 @classmethod |
490 @classmethod |
479 def fromrule(cls, state, rule): |
491 def fromrule(cls, state, rule): |
480 """Parses the given rule, returning an instance of the histeditaction. |
492 """Parses the given rule, returning an instance of the histeditaction.""" |
481 """ |
|
482 ruleid = rule.strip().split(b' ', 1)[0] |
493 ruleid = rule.strip().split(b' ', 1)[0] |
483 # ruleid can be anything from rev numbers, hashes, "bookmarks" etc |
494 # ruleid can be anything from rev numbers, hashes, "bookmarks" etc |
484 # Check for validation of rule ids and get the rulehash |
495 # Check for validation of rule ids and get the rulehash |
485 try: |
496 try: |
486 rev = node.bin(ruleid) |
497 rev = node.bin(ruleid) |
542 maxlen = max(maxlen, 22) # avoid truncating hash |
553 maxlen = max(maxlen, 22) # avoid truncating hash |
543 return stringutil.ellipsis(line, maxlen) |
554 return stringutil.ellipsis(line, maxlen) |
544 |
555 |
545 def tostate(self): |
556 def tostate(self): |
546 """Print an action in format used by histedit state files |
557 """Print an action in format used by histedit state files |
547 (the first line is a verb, the remainder is the second) |
558 (the first line is a verb, the remainder is the second) |
548 """ |
559 """ |
549 return b"%s\n%s" % (self.verb, node.hex(self.node)) |
560 return b"%s\n%s" % (self.verb, node.hex(self.node)) |
550 |
561 |
551 def run(self): |
562 def run(self): |
552 """Runs the action. The default behavior is simply apply the action's |
563 """Runs the action. The default behavior is simply apply the action's |
1176 return self.conflicts |
1187 return self.conflicts |
1177 |
1188 |
1178 |
1189 |
1179 # ============ EVENTS =============== |
1190 # ============ EVENTS =============== |
1180 def movecursor(state, oldpos, newpos): |
1191 def movecursor(state, oldpos, newpos): |
1181 '''Change the rule/changeset that the cursor is pointing to, regardless of |
1192 """Change the rule/changeset that the cursor is pointing to, regardless of |
1182 current mode (you can switch between patches from the view patch window).''' |
1193 current mode (you can switch between patches from the view patch window).""" |
1183 state[b'pos'] = newpos |
1194 state[b'pos'] = newpos |
1184 |
1195 |
1185 mode, _ = state[b'mode'] |
1196 mode, _ = state[b'mode'] |
1186 if mode == MODE_RULES: |
1197 if mode == MODE_RULES: |
1187 # Scroll through the list by updating the view for MODE_RULES, so that |
1198 # Scroll through the list by updating the view for MODE_RULES, so that |
1254 index -= 1 |
1265 index -= 1 |
1255 changeaction(state, pos, KEY_LIST[index % len(KEY_LIST)]) |
1266 changeaction(state, pos, KEY_LIST[index % len(KEY_LIST)]) |
1256 |
1267 |
1257 |
1268 |
1258 def changeview(state, delta, unit): |
1269 def changeview(state, delta, unit): |
1259 '''Change the region of whatever is being viewed (a patch or the list of |
1270 """Change the region of whatever is being viewed (a patch or the list of |
1260 changesets). 'delta' is an amount (+/- 1) and 'unit' is 'page' or 'line'.''' |
1271 changesets). 'delta' is an amount (+/- 1) and 'unit' is 'page' or 'line'.""" |
1261 mode, _ = state[b'mode'] |
1272 mode, _ = state[b'mode'] |
1262 if mode != MODE_PATCH: |
1273 if mode != MODE_PATCH: |
1263 return |
1274 return |
1264 mode_state = state[b'modes'][mode] |
1275 mode_state = state[b'modes'][mode] |
1265 num_lines = len(mode_state[b'patchcontents']) |
1276 num_lines = len(mode_state[b'patchcontents']) |