cmdutil: simplify duplicatecopies
authorMatt Mackall <mpm@selenic.com>
Thu, 05 Jan 2012 20:35:10 -0600
changeset 15777 12309c09d19a
parent 15776 55a85a55f020
child 15778 f15c646bffc7
cmdutil: simplify duplicatecopies
hgext/rebase.py
mercurial/cmdutil.py
mercurial/commands.py
tests/test-graft.t
--- a/hgext/rebase.py	Thu Jan 05 14:14:12 2012 -0600
+++ b/hgext/rebase.py	Thu Jan 05 20:35:10 2012 -0600
@@ -269,7 +269,7 @@
                                         'resolve, then hg rebase --continue)'))
                     finally:
                         ui.setconfig('ui', 'forcemerge', '')
-                cmdutil.duplicatecopies(repo, rev, target, p2)
+                cmdutil.duplicatecopies(repo, rev, target)
                 if not collapsef:
                     newrev = concludenode(repo, rev, p1, p2, extrafn=extrafn,
                                           editor=editor)
--- a/mercurial/cmdutil.py	Thu Jan 05 14:14:12 2012 -0600
+++ b/mercurial/cmdutil.py	Thu Jan 05 20:35:10 2012 -0600
@@ -1198,18 +1198,10 @@
         bad.extend(f for f in rejected if f in match.files())
     return bad
 
-def duplicatecopies(repo, rev, p1, p2):
+def duplicatecopies(repo, rev, p1):
     "Reproduce copies found in the source revision in the dirstate for grafts"
-    # Here we simulate the copies and renames in the source changeset
-    cop, diver = copies.mergecopies(repo, repo[rev], repo[p1], repo[p2])
-    m1 = repo[rev].manifest()
-    m2 = repo[p1].manifest()
-    for k, v in cop.iteritems():
-        if k in m1:
-            if v in m1 or v in m2:
-                repo.dirstate.copy(v, k)
-                if v in m2 and v not in m1 and k in m2:
-                    repo.dirstate.remove(v)
+    for dst, src in copies.pathcopies(repo[p1], repo[rev]).iteritems():
+        repo.dirstate.copy(src, dst)
 
 def commit(ui, repo, commitfunc, pats, opts):
     '''commit the specified files or all outstanding changes'''
--- a/mercurial/commands.py	Thu Jan 05 14:14:12 2012 -0600
+++ b/mercurial/commands.py	Thu Jan 05 20:35:10 2012 -0600
@@ -2627,7 +2627,7 @@
             repo.dirstate.setparents(current.node(), nullid)
             repo.dirstate.write()
             # fix up dirstate for copies and renames
-            cmdutil.duplicatecopies(repo, ctx.rev(), current.node(), nullid)
+            cmdutil.duplicatecopies(repo, ctx.rev(), current.node())
             # report any conflicts
             if stats and stats[3] > 0:
                 # write out state for --continue
--- a/tests/test-graft.t	Thu Jan 05 14:14:12 2012 -0600
+++ b/tests/test-graft.t	Thu Jan 05 20:35:10 2012 -0600
@@ -106,14 +106,6 @@
    b: local copied/moved to a -> m
   preserving b for resolve of b
   updating: b 1/1 files (100.00%)
-    searching for copies back to rev 1
-    unmatched files in local:
-     a
-    unmatched files in other:
-     b
-    all copies found (* = to merge, ! = divergent):
-     b -> a *
-    checking for directory renames
   b
    b: searching for copy revision for a
    b: copy a:b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3
@@ -127,12 +119,6 @@
    e: remote is newer -> g
   updating: e 1/1 files (100.00%)
   getting e
-    searching for copies back to rev 1
-    unmatched files in local:
-     c
-    all copies found (* = to merge, ! = divergent):
-     c -> b *
-    checking for directory renames
   e
   grafting revision 4
     searching for copies back to rev 1
@@ -152,12 +138,6 @@
   my e@77eb504366ab+ other e@9c233e8e184d ancestor e@68795b066622
   warning: conflicts during merge.
   merging e incomplete! (edit conflicts, then use 'hg resolve --mark')
-    searching for copies back to rev 1
-    unmatched files in local:
-     c
-    all copies found (* = to merge, ! = divergent):
-     c -> b *
-    checking for directory renames
   abort: unresolved conflicts, can't continue
   (use hg resolve and hg graft --continue)
   [255]