diff --git a/hgext/fix.py b/hgext/fix.py --- a/hgext/fix.py +++ b/hgext/fix.py @@ -239,9 +239,11 @@ replacerev(ui, repo, ctx, filedata[rev], replacements) del filedata[rev] - cleanup(repo, replacements, wdirwritten) + cleanup(repo, replacements, wdirwritten, fixers) -def cleanup(repo, replacements, wdirwritten): +# Do not inline this function or remove unused arguments. They are meant as a +# wrapping point for further extensions. +def cleanup(repo, replacements, wdirwritten, fixers): """Calls scmutil.cleanupnodes() with the given replacements. "replacements" is a dict from nodeid to nodeid, with one key and one value @@ -251,6 +253,10 @@ "wdirwritten" is a bool which tells whether the working copy was affected by fixing, since it has no entry in "replacements". + "fixers" is the list of fixer tools that was used, in case we want to clean + up something they dirtied (though they currently have no side effects within + this extension). + Useful as a hook point for extending "hg fix" with output summarizing the effects of the command, though we choose not to output anything here. """ @@ -497,7 +503,7 @@ for fixername, fixer in fixers.iteritems(): if fixer.affects(opts, fixctx, path): rangesfn = lambda: lineranges(opts, path, basectxs, fixctx, newdata) - command = fixer.command(ui, path, rangesfn) + command = fixer.command(ui, fixctx, path, rangesfn) if command is None: continue ui.debug('subprocess: %s\n' % (command,)) @@ -652,6 +658,7 @@ setattr(fixers[name], pycompat.sysstr('_' + key), attrs.get(key, default)) fixers[name]._priority = int(fixers[name]._priority) + fixers[name].name = name return collections.OrderedDict( sorted(fixers.items(), key=lambda item: item[1]._priority, reverse=True)) @@ -671,11 +678,13 @@ """Should this fixer run on the file at the given path and context?""" return scmutil.match(fixctx, [self._pattern], opts)(path) - def command(self, ui, path, rangesfn): + def command(self, ui, ctx, path, rangesfn): """A shell command to use to invoke this fixer on the given file/lines May return None if there is no appropriate command to run for the given parameters. + + "ctx" is unused, but it is meant for use by further extensions. """ expand = cmdutil.rendercommandtemplate parts = [expand(ui, self._command,