Patchwork [1,of,2,v2] cmdutil: add copy-filtering support to duplicatecopies

login
register
mail settings
Submitter Augie Fackler
Date June 24, 2014, 6:37 p.m.
Message ID <b7af93b6c0abd7b3fa8e.1403635033@augie-macbookair>
Download mbox | patch
Permalink /patch/5053/
State Accepted
Commit 3666331164bb014b9b7b2a56d4171ef4cbb5e4d6
Headers show

Comments

Augie Fackler - June 24, 2014, 6:37 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1402168476 14400
#      Sat Jun 07 15:14:36 2014 -0400
# Node ID b7af93b6c0abd7b3fa8e518062d84f8d7690e114
# Parent  15baed3f24ee98a7aaecfaf9b8c93e3695c9a813
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.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1944,11 +1944,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)