Patchwork D8595: copies: make _chain() and _filter() public

login
register
mail settings
Submitter phabricator
Date May 29, 2020, 3:58 p.m.
Message ID <differential-rev-PHID-DREV-3sorjjtdlxsmsmmgkdms-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46391/
State New
Headers show

Comments

phabricator - May 29, 2020, 3:58 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -30,10 +30,10 @@ 
 from .utils import stringutil
 
 
-def _filter(src, dst, t):
+def filter(src, dst, t):
     """filters out invalid copies after chaining"""
 
-    # When _chain()'ing copies in 'a' (from 'src' via some other commit 'mid')
+    # 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
@@ -47,10 +47,10 @@ 
     #   5   -   x   y    -
     #   6   x   x   y   x->y
     #
-    # _chain() takes care of chaining the copies in 'a' and 'b', but it
+    # chain() takes care of chaining the copies in 'a' and 'b', but it
     # cannot tell the difference between cases 1 and 2, between 3 and 4, or
     # between 5 and 6, so it includes all cases in its result.
-    # Cases 1, 3, and 5 are then removed by _filter().
+    # Cases 1, 3, and 5 are then removed by filter().
 
     for k, v in list(t.items()):
         # remove copies from files that didn't exist
@@ -64,7 +64,7 @@ 
             del t[k]
 
 
-def _chain(prefix, suffix):
+def chain(prefix, suffix):
     """chain two sets of copies 'prefix' and 'suffix'"""
     result = prefix.copy()
     for key, value in pycompat.iteritems(suffix):
@@ -435,7 +435,7 @@ 
     if b.rev() is None:
         cm = _committedforwardcopies(a, b.p1(), base, match)
         # combine copies from dirstate if necessary
-        copies = _chain(cm, _dirstatecopies(b._repo, match))
+        copies = chain(cm, _dirstatecopies(b._repo, match))
     else:
         copies = _committedforwardcopies(a, b, base, match)
     return copies
@@ -493,11 +493,11 @@ 
         base = None
         if a.rev() != node.nullrev:
             base = x
-        copies = _chain(
+        copies = chain(
             _backwardrenames(x, a, match=match),
             _forwardcopies(a, y, base, match=match),
         )
-    _filter(x, y, copies)
+    filter(x, y, copies)
     return copies
 
 
@@ -989,7 +989,7 @@ 
     by merge.update().
     """
     new_copies = pathcopies(base, ctx)
-    _filter(wctx.p1(), wctx, new_copies)
+    filter(wctx.p1(), wctx, new_copies)
     for dst, src in pycompat.iteritems(new_copies):
         wctx[dst].markcopied(src)