[Request] [+- ] D8722: fix: obtain base paths before starting workers
rdamazio (Rodrigo Damazio Bovendorp)
phabricator at mercurial-scm.org
Fri Jul 10 06:45:25 UTC 2020
rdamazio created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This moves calculation of base paths to before work is dispatched.
While this does mean that copy tracing will be serialized instead of
parallel, it is necessary to be able to prefetch the base contents
in a batch, which will likely be more efficient.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D8722
AFFECTED FILES
hgext/fix.py
CHANGE DETAILS
diff --git a/hgext/fix.py b/hgext/fix.py
--- a/hgext/fix.py
+++ b/hgext/fix.py
@@ -268,6 +268,7 @@
workqueue, numitems = getworkqueue(
ui, repo, pats, opts, revstofix, basectxs
)
+ basepaths = getbasepaths(repo, opts, workqueue, basectxs)
fixers = getfixers(ui)
# There are no data dependencies between the workers fixing each file
@@ -277,7 +278,7 @@
ctx = repo[rev]
olddata = ctx[path].data()
metadata, newdata = fixfile(
- ui, repo, opts, fixers, ctx, path, basectxs[rev]
+ ui, repo, opts, fixers, ctx, path, basepaths, basectxs[rev]
)
# Don't waste memory/time passing unchanged content back, but
# produce one result per item either way.
@@ -473,7 +474,8 @@
return files
-def lineranges(opts, path, basectxs, fixctx, content2):
+
+def lineranges(opts, path, basepaths, basectxs, fixctx, content2):
"""Returns the set of line ranges that should be fixed in a file
Of the form [(10, 20), (30, 40)].
@@ -492,7 +494,8 @@
rangeslist = []
for basectx in basectxs:
- basepath = copies.pathcopies(basectx, fixctx).get(path, path)
+ basepath = basepaths.get((basectx.rev(), fixctx.rev(), path), path)
+
if basepath in basectx:
content1 = basectx[basepath].data()
else:
@@ -501,6 +504,21 @@
return unionranges(rangeslist)
+def getbasepaths(repo, opts, workqueue, basectxs):
+ if opts.get(b'whole'):
+ # Base paths will never be fetched for line range determination.
+ return {}
+
+ basepaths = {}
+ for rev, path in workqueue:
+ fixctx = repo[rev]
+ for basectx in basectxs[rev]:
+ basepath = copies.pathcopies(basectx, fixctx).get(path, path)
+ if basepath in basectx:
+ basepaths[(basectx.rev(), fixctx.rev(), path)] = basepath
+ return basepaths
+
+
def unionranges(rangeslist):
"""Return the union of some closed intervals
@@ -613,7 +631,7 @@
return basectxs
-def fixfile(ui, repo, opts, fixers, fixctx, path, basectxs):
+def fixfile(ui, repo, opts, fixers, fixctx, path, basepaths, basectxs):
"""Run any configured fixers that should affect the file in this context
Returns the file content that results from applying the fixers in some order
@@ -629,7 +647,8 @@
newdata = fixctx[path].data()
for fixername, fixer in pycompat.iteritems(fixers):
if fixer.affects(opts, fixctx, path):
- ranges = lineranges(opts, path, basectxs, fixctx, newdata)
+ ranges = lineranges(
+ opts, path, basepaths, basectxs, fixctx, newdata)
command = fixer.command(ui, path, ranges)
if command is None:
continue
To: rdamazio, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200710/e95441eb/attachment-0001.html>
More information about the Mercurial-patches
mailing list