Mercurial > hg
comparison mercurial/copies.py @ 44093:06e7e7652ac0
graftcopies: document why the function is useful at all
Despite having spent a significant amount on time on the copy-tracing
code, I thought `graftcopies()` (formerly known as
`duplicatecopies()`) was needed to duplicate copies after calling
`merge.update()` to do a merge (as `merge.graft()` does), but it's
actually usually not needed; `merge.update()` takes care of most
copies. This patch documents what the function is for.
Differential Revision: https://phab.mercurial-scm.org/D7861
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Sun, 29 Dec 2019 17:53:48 -0800 |
parents | 833210fbd900 |
children | baf3fe2977cc |
comparison
equal
deleted
inserted
replaced
44092:833210fbd900 | 44093:06e7e7652ac0 |
---|---|
855 except StopIteration: | 855 except StopIteration: |
856 return False | 856 return False |
857 | 857 |
858 | 858 |
859 def graftcopies(wctx, ctx, base): | 859 def graftcopies(wctx, ctx, base): |
860 """reproduce copies between base and ctx in the wctx""" | 860 """reproduce copies between base and ctx in the wctx |
861 | |
862 Unlike mergecopies(), this function will only consider copies between base | |
863 and ctx; it will ignore copies between base and wctx. Also unlike | |
864 mergecopies(), this function will apply copies to the working copy (instead | |
865 of just returning information about the copies). That makes it cheaper | |
866 (especially in the common case of base==ctx.p1()) and useful also when | |
867 experimental.copytrace=off. | |
868 | |
869 merge.update() will have already marked most copies, but it will only | |
870 mark copies if it thinks the source files are related (see | |
871 merge._related()). It will also not mark copies if the file wasn't modified | |
872 on the local side. This function adds the copies that were "missed" | |
873 by merge.update(). | |
874 """ | |
861 new_copies = pathcopies(base, ctx) | 875 new_copies = pathcopies(base, ctx) |
862 _filter(wctx.p1(), wctx, new_copies) | 876 _filter(wctx.p1(), wctx, new_copies) |
863 for dst, src in pycompat.iteritems(new_copies): | 877 for dst, src in pycompat.iteritems(new_copies): |
864 wctx[dst].markcopied(src) | 878 wctx[dst].markcopied(src) |
865 | 879 |