##// END OF EJS Templates
fix: obtain base paths before starting workers...
Rodrigo Damazio Bovendorp -
r45614:f204ba74 default draft
parent child Browse files
Show More
@@ -268,6 +268,7 b' def fix(ui, repo, *pats, **opts):'
268 workqueue, numitems = getworkqueue(
268 workqueue, numitems = getworkqueue(
269 ui, repo, pats, opts, revstofix, basectxs
269 ui, repo, pats, opts, revstofix, basectxs
270 )
270 )
271 basepaths = getbasepaths(repo, opts, workqueue, basectxs)
271 fixers = getfixers(ui)
272 fixers = getfixers(ui)
272
273
273 # There are no data dependencies between the workers fixing each file
274 # There are no data dependencies between the workers fixing each file
@@ -277,7 +278,7 b' def fix(ui, repo, *pats, **opts):'
277 ctx = repo[rev]
278 ctx = repo[rev]
278 olddata = ctx[path].data()
279 olddata = ctx[path].data()
279 metadata, newdata = fixfile(
280 metadata, newdata = fixfile(
280 ui, repo, opts, fixers, ctx, path, basectxs[rev]
281 ui, repo, opts, fixers, ctx, path, basepaths, basectxs[rev]
281 )
282 )
282 # Don't waste memory/time passing unchanged content back, but
283 # Don't waste memory/time passing unchanged content back, but
283 # produce one result per item either way.
284 # produce one result per item either way.
@@ -473,7 +474,8 b' def pathstofix(ui, repo, pats, opts, mat'
473 return files
474 return files
474
475
475
476
476 def lineranges(opts, path, basectxs, fixctx, content2):
477
478 def lineranges(opts, path, basepaths, basectxs, fixctx, content2):
477 """Returns the set of line ranges that should be fixed in a file
479 """Returns the set of line ranges that should be fixed in a file
478
480
479 Of the form [(10, 20), (30, 40)].
481 Of the form [(10, 20), (30, 40)].
@@ -492,7 +494,8 b' def lineranges(opts, path, basectxs, fix'
492
494
493 rangeslist = []
495 rangeslist = []
494 for basectx in basectxs:
496 for basectx in basectxs:
495 basepath = copies.pathcopies(basectx, fixctx).get(path, path)
497 basepath = basepaths.get((basectx.rev(), fixctx.rev(), path), path)
498
496 if basepath in basectx:
499 if basepath in basectx:
497 content1 = basectx[basepath].data()
500 content1 = basectx[basepath].data()
498 else:
501 else:
@@ -501,6 +504,21 b' def lineranges(opts, path, basectxs, fix'
501 return unionranges(rangeslist)
504 return unionranges(rangeslist)
502
505
503
506
507 def getbasepaths(repo, opts, workqueue, basectxs):
508 if opts.get(b'whole'):
509 # Base paths will never be fetched for line range determination.
510 return {}
511
512 basepaths = {}
513 for rev, path in workqueue:
514 fixctx = repo[rev]
515 for basectx in basectxs[rev]:
516 basepath = copies.pathcopies(basectx, fixctx).get(path, path)
517 if basepath in basectx:
518 basepaths[(basectx.rev(), fixctx.rev(), path)] = basepath
519 return basepaths
520
521
504 def unionranges(rangeslist):
522 def unionranges(rangeslist):
505 """Return the union of some closed intervals
523 """Return the union of some closed intervals
506
524
@@ -613,7 +631,7 b' def getbasectxs(repo, opts, revstofix):'
613 return basectxs
631 return basectxs
614
632
615
633
616 def fixfile(ui, repo, opts, fixers, fixctx, path, basectxs):
634 def fixfile(ui, repo, opts, fixers, fixctx, path, basepaths, basectxs):
617 """Run any configured fixers that should affect the file in this context
635 """Run any configured fixers that should affect the file in this context
618
636
619 Returns the file content that results from applying the fixers in some order
637 Returns the file content that results from applying the fixers in some order
@@ -629,7 +647,8 b' def fixfile(ui, repo, opts, fixers, fixc'
629 newdata = fixctx[path].data()
647 newdata = fixctx[path].data()
630 for fixername, fixer in pycompat.iteritems(fixers):
648 for fixername, fixer in pycompat.iteritems(fixers):
631 if fixer.affects(opts, fixctx, path):
649 if fixer.affects(opts, fixctx, path):
632 ranges = lineranges(opts, path, basectxs, fixctx, newdata)
650 ranges = lineranges(
651 opts, path, basepaths, basectxs, fixctx, newdata)
633 command = fixer.command(ui, path, ranges)
652 command = fixer.command(ui, path, ranges)
634 if command is None:
653 if command is None:
635 continue
654 continue
General Comments 0
You need to be logged in to leave comments. Login now