D10118: copies: extract function _backwardcopies() for reversing renames
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Sat Mar 6 00:41:20 UTC 2021
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
I'll add another callers in the next patch.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10118
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
@@ -704,22 +704,28 @@
def _backwardrenames(a, b, match):
+ """find renames from a to b"""
if a._repo.ui.config(b'experimental', b'copytrace') == b'off':
return {}
+ # We don't want to pass in "match" here, since that would filter
+ # the destination by it. Since we're reversing the copies, we want
+ # to filter the source instead.
+ copies = _forwardcopies(b, a)
+ return _reverse_renames(copies, a, match)
+
+
+def _reverse_renames(copies, dst, match):
+ """given copies to context 'dst', finds renames from that context"""
# Even though we're not taking copies into account, 1:n rename situations
# can still exist (e.g. hg cp a b; hg mv a c). In those cases we
# arbitrarily pick one of the renames.
- # We don't want to pass in "match" here, since that would filter
- # the destination by it. Since we're reversing the copies, we want
- # to filter the source instead.
- f = _forwardcopies(b, a)
r = {}
- for k, v in sorted(pycompat.iteritems(f)):
+ for k, v in sorted(pycompat.iteritems(copies)):
if match and not match(v):
continue
# remove copies
- if v in a:
+ if v in dst:
continue
r[v] = k
return r
To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list