##// END OF EJS Templates
fix: compute changed lines lazily to make whole-file fixer tools faster...
Danny Hooper -
r38896:257c9846 default
parent child Browse files
Show More
@@ -436,8 +436,8 b' def fixfile(ui, opts, fixers, fixctx, pa'
436 newdata = fixctx[path].data()
436 newdata = fixctx[path].data()
437 for fixername, fixer in fixers.iteritems():
437 for fixername, fixer in fixers.iteritems():
438 if fixer.affects(opts, fixctx, path):
438 if fixer.affects(opts, fixctx, path):
439 ranges = lineranges(opts, path, basectxs, fixctx, newdata)
439 rangesfn = lambda: lineranges(opts, path, basectxs, fixctx, newdata)
440 command = fixer.command(ui, path, ranges)
440 command = fixer.command(ui, path, rangesfn)
441 if command is None:
441 if command is None:
442 continue
442 continue
443 ui.debug('subprocess: %s\n' % (command,))
443 ui.debug('subprocess: %s\n' % (command,))
@@ -582,7 +582,7 b' class Fixer(object):'
582 """Should this fixer run on the file at the given path and context?"""
582 """Should this fixer run on the file at the given path and context?"""
583 return scmutil.match(fixctx, [self._fileset], opts)(path)
583 return scmutil.match(fixctx, [self._fileset], opts)(path)
584
584
585 def command(self, ui, path, ranges):
585 def command(self, ui, path, rangesfn):
586 """A shell command to use to invoke this fixer on the given file/lines
586 """A shell command to use to invoke this fixer on the given file/lines
587
587
588 May return None if there is no appropriate command to run for the given
588 May return None if there is no appropriate command to run for the given
@@ -592,6 +592,7 b' class Fixer(object):'
592 parts = [expand(ui, self._command,
592 parts = [expand(ui, self._command,
593 {'rootpath': path, 'basename': os.path.basename(path)})]
593 {'rootpath': path, 'basename': os.path.basename(path)})]
594 if self._linerange:
594 if self._linerange:
595 ranges = rangesfn()
595 if not ranges:
596 if not ranges:
596 # No line ranges to fix, so don't run the fixer.
597 # No line ranges to fix, so don't run the fixer.
597 return None
598 return None
General Comments 0
You need to be logged in to leave comments. Login now