Comments
Patch
@@ -330,6 +330,11 @@ class histeditaction(object):
raise util.Abort(_('unknown changeset %s listed') % rulehash[:12])
return cls(state, node)
+ @classmethod
+ def preprocess(cls, rules):
+ """Preprocess rules and potentially transform the ruleset."""
+ return rules
+
def run(self):
"""Runs the action. The default behavior is simply apply the action's
rulectx onto the current parentctx."""
@@ -616,6 +621,20 @@ class _multifold(fold):
def skipprompt(self):
return True
+ @classmethod
+ def preprocess(cls, rules):
+ """Preprocess rules and potentially transform the ruleset.
+
+ Note that at present there are no guarantees around the
+ ordering of the preprocessing actions taken.
+ """
+ newrules = rules[:]
+ for idx, ((action, ha), (nextact, unused)) in enumerate(
+ zip(rules, rules[1:] + [(None, None)])):
+ if action == 'fold' and nextact == 'fold':
+ newrules[idx] = '_multifold', ha
+ rules[:] = newrules[:]
+
class rollup(fold):
def mergedescs(self):
return False
@@ -869,13 +888,8 @@ def _histedit(ui, repo, state, *freeargs
'histedit')
state.backupfile = backupfile
- # preprocess rules so that we can hide inner folds from the user
- # and only show one editor
- rules = state.rules[:]
- for idx, ((action, ha), (nextact, unused)) in enumerate(
- zip(rules, rules[1:] + [(None, None)])):
- if action == 'fold' and nextact == 'fold':
- state.rules[idx] = '_multifold', ha
+ for ruletype in set(actiontable.values()):
+ ruletype.preprocess(state.rules)
while state.rules:
state.write()