copies: inline _chainandfilter() to prepare for next patch
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 25 Jun 2019 13:46:55 -0700
changeset 42593 11ceb1b8fd74
parent 42592 a48f6f18dc6d
child 42594 d013099c551b
copies: inline _chainandfilter() to prepare for next patch Differential Revision: https://phab.mercurial-scm.org/D6602
mercurial/copies.py
--- a/mercurial/copies.py	Tue Jun 25 13:33:49 2019 -0700
+++ b/mercurial/copies.py	Tue Jun 25 13:46:55 2019 -0700
@@ -107,13 +107,13 @@
     # This only occurs when a is a descendent of b or visa-versa.
     return min(limit, a, b)
 
-def _chainandfilter(src, dst, a, b):
-    """chain two sets of copies 'a' and 'b' and filter result"""
+def _filter(src, dst, t):
+    """filters out invalid copies after chaining"""
 
-    # When chaining copies in 'a' (from 'src' via some other commit 'mid') with
-    # copies in 'b' (from 'mid' to 'dst'), we can get the different cases in the
-    # following table (not including trivial cases). For example, case 2 is
-    # where a file existed in 'src' and remained under that name in 'mid' and
+    # When _chain()'ing copies in 'a' (from 'src' via some other commit 'mid')
+    # with copies in 'b' (from 'mid' to 'dst'), we can get the different cases
+    # in the following table (not including trivial cases). For example, case 2
+    # is where a file existed in 'src' and remained under that name in 'mid' and
     # then was renamed between 'mid' and 'dst'.
     #
     # case src mid dst result
@@ -129,12 +129,6 @@
     # between 5 and 6, so it includes all cases in its result.
     # Cases 1, 3, and 5 are then removed by _filter().
 
-    t = _chain(a, b)
-    _filter(src, dst, t)
-    return t
-
-def _filter(src, dst, t):
-    """filters out invalid copies after chaining"""
     for k, v in list(t.items()):
         # remove copies from files that didn't exist
         if v not in src:
@@ -326,7 +320,8 @@
     if b.rev() is None:
         cm = _committedforwardcopies(a, b.p1(), match)
         # combine copies from dirstate if necessary
-        copies = _chainandfilter(a, b, cm, _dirstatecopies(b._repo, match))
+        copies = _chain(cm, _dirstatecopies(b._repo, match))
+        _filter(a, b, copies)
     else:
         copies  = _committedforwardcopies(a, b, match)
     return copies
@@ -376,8 +371,9 @@
     else:
         if debug:
             repo.ui.debug('debug.copies: search mode: combined\n')
-        copies = _chainandfilter(x, y, _backwardrenames(x, a, match=match),
-                                 _forwardcopies(a, y, match=match))
+        copies = _chain(_backwardrenames(x, a, match=match),
+                        _forwardcopies(a, y, match=match))
+        _filter(x, y, copies)
     return copies
 
 def mergecopies(repo, c1, c2, base):