From patchwork Sat Jun 7 19:25:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,2] cmdutil: add copy-filtering support to duplicatecopies From: Augie Fackler X-Patchwork-Id: 4948 Message-Id: To: mercurial-devel@selenic.com Date: Sat, 07 Jun 2014 15:25:12 -0400 # HG changeset patch # User Augie Fackler # Date 1402168476 14400 # Sat Jun 07 15:14:36 2014 -0400 # Node ID c55e9be3df7003c99d19f42fcad9a4ebe6eb2ab1 # Parent 7afe70a5d2ad5b22c21ba9be849451407c1f337f 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. 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)