changeset 22901:722117c8e023

duplicatecopies: move from cmdutil to copies This is in preparation for moving its primary caller into merge.py, which would be a layering violation in the current location.
author Matt Mackall <mpm@selenic.com>
date Mon, 13 Oct 2014 14:33:13 -0500
parents 7bf82faba774
children ce0592328d68
files hgext/histedit.py hgext/rebase.py mercurial/cmdutil.py mercurial/commands.py mercurial/copies.py
diffstat 5 files changed, 25 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Mon Oct 13 14:04:11 2014 -0500
+++ b/hgext/histedit.py	Mon Oct 13 14:33:13 2014 -0500
@@ -234,7 +234,7 @@
         repo.dirstate.endparentchange()
         repo.dirstate.write()
         # fix up dirstate for copies and renames
-        cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
+        copies.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
     return stats
 
 def collapse(repo, first, last, commitopts):
--- a/hgext/rebase.py	Mon Oct 13 14:04:11 2014 -0500
+++ b/hgext/rebase.py	Mon Oct 13 14:33:13 2014 -0500
@@ -16,6 +16,7 @@
 
 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks
 from mercurial import extensions, patch, scmutil, phases, obsolete, error
+from mercurial import copies
 from mercurial.commands import templateopts
 from mercurial.node import nullrev
 from mercurial.lock import release
@@ -382,7 +383,7 @@
                     finally:
                         ui.setconfig('ui', 'forcemerge', '', 'rebase')
                 if collapsef:
-                    cmdutil.duplicatecopies(repo, rev, target)
+                    copies.duplicatecopies(repo, rev, target)
                 else:
                     # If we're not using --collapse, we need to
                     # duplicate copies between the revision we're
@@ -390,7 +391,7 @@
                     # duplicate any copies that have already been
                     # performed in the destination.
                     p1rev = repo[rev].p1().rev()
-                    cmdutil.duplicatecopies(repo, rev, p1rev, skiprev=target)
+                    copies.duplicatecopies(repo, rev, p1rev, skiprev=target)
                 if not collapsef:
                     merging = repo[p2].rev() != nullrev
                     editform = cmdutil.mergeeditform(merging, 'rebase')
--- a/mercurial/cmdutil.py	Mon Oct 13 14:04:11 2014 -0500
+++ b/mercurial/cmdutil.py	Mon Oct 13 14:33:13 2014 -0500
@@ -2105,25 +2105,6 @@
 
     return err
 
-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)
-
 def commit(ui, repo, commitfunc, pats, opts):
     '''commit the specified files or all outstanding changes'''
     date = opts.get('date')
--- a/mercurial/commands.py	Mon Oct 13 14:04:11 2014 -0500
+++ b/mercurial/commands.py	Mon Oct 13 14:33:13 2014 -0500
@@ -18,7 +18,7 @@
 from hgweb import server as hgweb_server
 import merge as mergemod
 import minirst, revset, fileset
-import dagparser, context, simplemerge, graphmod
+import dagparser, context, simplemerge, graphmod, copies
 import random
 import setdiscovery, treediscovery, dagutil, pvec, localrepo
 import phases, obsolete, exchange
@@ -3490,7 +3490,7 @@
                     repo.setparents(current.node(), nullid)
                     repo.dirstate.write()
                     # fix up dirstate for copies and renames
-                    cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
+                    copies.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
                     repo.dirstate.endparentchange()
                 finally:
                     repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
--- a/mercurial/copies.py	Mon Oct 13 14:04:11 2014 -0500
+++ b/mercurial/copies.py	Mon Oct 13 14:33:13 2014 -0500
@@ -420,3 +420,22 @@
 
     if of in ma:
         diverge.setdefault(of, []).append(f)
+
+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 = pathcopies(repo[fromrev], repo[skiprev])
+    for dst, src in 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)