D6602: copies: inline _chainandfilter() to prepare for next patch

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Jul 4 15:00:28 UTC 2019


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6602

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
@@ -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):



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list