Mercurial > public > mercurial-scm > hg
comparison mercurial/copies.py @ 44090:2f0a44c69e07
copies: replace duplicatecopies() by function that takes contexts
The callers mostly have context objects, so let's avoid looking up the
same context objects inside `duplicatecopies()`.
I also renamed the function to `graftcopies()` since I think that
better matches its purpose. I did it in the same commit so it's easier
for extensions to switch between the functions.
Differential Revision: https://phab.mercurial-scm.org/D7858
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 06 Jan 2020 15:24:36 -0800 |
parents | acbb55b8e9dc |
children | 3df0bd706c40 |
comparison
equal
deleted
inserted
replaced
44089:bd22e90c54b3 | 44090:2f0a44c69e07 |
---|---|
854 return f1 == f2 # true if they point to the same file | 854 return f1 == f2 # true if they point to the same file |
855 except StopIteration: | 855 except StopIteration: |
856 return False | 856 return False |
857 | 857 |
858 | 858 |
859 def duplicatecopies(repo, wctx, rev, fromrev, skiprev=None): | 859 def graftcopies(repo, wctx, ctx, base, skip=None): |
860 """reproduce copies from fromrev to rev in the dirstate | 860 """reproduce copies between base and ctx in the wctx |
861 | 861 |
862 If skiprev is specified, it's a revision that should be used to | 862 If skip is specified, it's a revision that should be used to |
863 filter copy records. Any copies that occur between fromrev and | 863 filter copy records. Any copies that occur between base and |
864 skiprev will not be duplicated, even if they appear in the set of | 864 skip will not be duplicated, even if they appear in the set of |
865 copies between fromrev and rev. | 865 copies between base and ctx. |
866 """ | 866 """ |
867 exclude = {} | 867 exclude = {} |
868 ctraceconfig = repo.ui.config(b'experimental', b'copytrace') | 868 ctraceconfig = repo.ui.config(b'experimental', b'copytrace') |
869 bctrace = stringutil.parsebool(ctraceconfig) | 869 bctrace = stringutil.parsebool(ctraceconfig) |
870 if skiprev is not None and ( | 870 if skip is not None and ( |
871 ctraceconfig == b'heuristics' or bctrace or bctrace is None | 871 ctraceconfig == b'heuristics' or bctrace or bctrace is None |
872 ): | 872 ): |
873 # copytrace='off' skips this line, but not the entire function because | 873 # copytrace='off' skips this line, but not the entire function because |
874 # the line below is O(size of the repo) during a rebase, while the rest | 874 # the line below is O(size of the repo) during a rebase, while the rest |
875 # of the function is much faster (and is required for carrying copy | 875 # of the function is much faster (and is required for carrying copy |
876 # metadata across the rebase anyway). | 876 # metadata across the rebase anyway). |
877 exclude = pathcopies(repo[fromrev], repo[skiprev]) | 877 exclude = pathcopies(base, skip) |
878 for dst, src in pycompat.iteritems(pathcopies(repo[fromrev], repo[rev])): | 878 for dst, src in pycompat.iteritems(pathcopies(base, ctx)): |
879 if dst in exclude: | 879 if dst in exclude: |
880 continue | 880 continue |
881 if dst in wctx: | 881 if dst in wctx: |
882 wctx[dst].markcopied(src) | 882 wctx[dst].markcopied(src) |
883 | 883 |