hgext/fix.py
changeset 37774 d6970628b95f
parent 37618 1edf3738e000
child 38420 c1f4364f9336
--- a/hgext/fix.py	Fri Apr 13 23:07:12 2018 +0900
+++ b/hgext/fix.py	Sat Apr 14 00:30:39 2018 +0900
@@ -387,7 +387,7 @@
     for fixername, fixer in fixers.iteritems():
         if fixer.affects(opts, fixctx, path):
             ranges = lineranges(opts, path, basectxs, fixctx, newdata)
-            command = fixer.command(path, ranges)
+            command = fixer.command(ui, path, ranges)
             if command is None:
                 continue
             ui.debug('subprocess: %s\n' % (command,))
@@ -534,18 +534,20 @@
         """Should this fixer run on the file at the given path and context?"""
         return scmutil.match(fixctx, [self._fileset], opts)(path)
 
-    def command(self, path, ranges):
+    def command(self, ui, path, ranges):
         """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.
         """
-        parts = [self._command.format(rootpath=path,
-                                      basename=os.path.basename(path))]
+        expand = cmdutil.rendercommandtemplate
+        parts = [expand(ui, self._command,
+                        {'rootpath': path, 'basename': os.path.basename(path)})]
         if self._linerange:
             if not ranges:
                 # No line ranges to fix, so don't run the fixer.
                 return None
             for first, last in ranges:
-                parts.append(self._linerange.format(first=first, last=last))
+                parts.append(expand(ui, self._linerange,
+                                    {'first': first, 'last': last}))
         return ' '.join(parts)