changeset 21825:3666331164bb stable

cmdutil: add copy-filtering support to duplicatecopies In order to fix issue 4192 we need to be able to skip some copies while doing duplicatecopies.
author Augie Fackler <raf@durin42.com>
date Sat, 07 Jun 2014 15:14:36 -0400
parents 925d1bb9a971
children 2ba6c9b4e0eb
files mercurial/cmdutil.py
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sun Jun 29 13:52:35 2014 +0200
+++ b/mercurial/cmdutil.py	Sat Jun 07 15:14:36 2014 -0400
@@ -1913,11 +1913,22 @@
 
     return err
 
-def duplicatecopies(repo, rev, fromrev):
-    '''reproduce copies from fromrev to rev in the dirstate'''
+def duplicatecopies(repo, rev, fromrev, skiprev=None):
+    '''reproduce copies from fromrev to rev in the dirstate
+
+    If skiprev is specified, it's a revision that should be used to
+    filter copy records. Any copies that occur between fromrev and
+    skiprev will not be duplicated, even if they appear in the set of
+    copies between fromrev and rev.
+    '''
+    exclude = {}
+    if skiprev is not None:
+        exclude = copies.pathcopies(repo[fromrev], repo[skiprev])
     for dst, src in copies.pathcopies(repo[fromrev], repo[rev]).iteritems():
         # copies.pathcopies returns backward renames, so dst might not
         # actually be in the dirstate
+        if dst in exclude:
+            continue
         if repo.dirstate[dst] in "nma":
             repo.dirstate.copy(src, dst)