[Updated] D9567: copies: make calculating lazy for dir move detection's "addedfiles"
spectral (Kyle Lippincott)
phabricator at mercurial-scm.org
Sat Dec 12 07:56:48 UTC 2020
Closed by commit rHG2f357d053df2: copies: make calculating lazy for dir move detection's "addedfiles" (authored by spectral).
This revision was automatically updated to reflect the committed changes.
CHANGED PRIOR TO COMMIT
https://phab.mercurial-scm.org/D9567?vs=24186&id=24188#toc
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D9567?vs=24186&id=24188
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D9567/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D9567
AFFECTED FILES
mercurial/copies.py
CHANGE DETAILS
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -896,18 +896,33 @@
)
# find interesting file sets from manifests
- addedinm1 = m1.filesnotin(mb, repo.narrowmatch())
- addedinm2 = m2.filesnotin(mb, repo.narrowmatch())
- u1 = sorted(addedinm1 - addedinm2)
- u2 = sorted(addedinm2 - addedinm1)
+ cache = []
+
+ def _get_addedfiles(idx):
+ if not cache:
+ addedinm1 = m1.filesnotin(mb, repo.narrowmatch())
+ addedinm2 = m2.filesnotin(mb, repo.narrowmatch())
+ u1 = sorted(addedinm1 - addedinm2)
+ u2 = sorted(addedinm2 - addedinm1)
+ cache.extend((u1, u2))
+ return cache[idx]
- header = b" unmatched files in %s"
- if u1:
- repo.ui.debug(b"%s:\n %s\n" % (header % b'local', b"\n ".join(u1)))
- if u2:
- repo.ui.debug(b"%s:\n %s\n" % (header % b'other', b"\n ".join(u2)))
+ u1fn = lambda: _get_addedfiles(0)
+ u2fn = lambda: _get_addedfiles(1)
+ if repo.ui.debugflag:
+ u1 = u1fn()
+ u2 = u2fn()
- if repo.ui.debugflag:
+ header = b" unmatched files in %s"
+ if u1:
+ repo.ui.debug(
+ b"%s:\n %s\n" % (header % b'local', b"\n ".join(u1))
+ )
+ if u2:
+ repo.ui.debug(
+ b"%s:\n %s\n" % (header % b'other', b"\n ".join(u2))
+ )
+
renamedeleteset = set()
divergeset = set()
for dsts in diverge.values():
@@ -941,8 +956,8 @@
repo.ui.debug(b" checking for directory renames\n")
- dirmove1, movewithdir2 = _dir_renames(repo, c1, copy1, copies1, u2)
- dirmove2, movewithdir1 = _dir_renames(repo, c2, copy2, copies2, u1)
+ dirmove1, movewithdir2 = _dir_renames(repo, c1, copy1, copies1, u2fn)
+ dirmove2, movewithdir1 = _dir_renames(repo, c2, copy2, copies2, u1fn)
branch_copies1 = branch_copies(copy1, renamedelete1, dirmove1, movewithdir1)
branch_copies2 = branch_copies(copy2, renamedelete2, dirmove2, movewithdir2)
@@ -950,14 +965,15 @@
return branch_copies1, branch_copies2, diverge
-def _dir_renames(repo, ctx, copy, fullcopy, addedfiles):
+def _dir_renames(repo, ctx, copy, fullcopy, addedfilesfn):
"""Finds moved directories and files that should move with them.
ctx: the context for one of the sides
copy: files copied on the same side (as ctx)
fullcopy: files copied on the same side (as ctx), including those that
merge.manifestmerge() won't care about
- addedfiles: added files on the other side (compared to ctx)
+ addedfilesfn: function returning added files on the other side (compared to
+ ctx)
"""
# generate a directory move map
invalid = set()
@@ -997,7 +1013,7 @@
movewithdir = {}
# check unaccounted nonoverlapping files against directory moves
- for f in addedfiles:
+ for f in addedfilesfn():
if f not in fullcopy:
for d in dirmove:
if f.startswith(d):
To: spectral, #hg-reviewers, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20201212/0367a8f2/attachment-0002.html>
More information about the Mercurial-patches
mailing list