changeset 3308:ecc1bf27378c

merge: unify merge and copy actions
author Matt Mackall <mpm@selenic.com>
date Tue, 10 Oct 2006 00:41:55 -0500
parents f009a6f12a59
children e8be5942335d
files mercurial/merge.py tests/test-rename-merge1.out tests/test-rename-merge2.out
diffstat 3 files changed, 29 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Tue Oct 10 00:32:30 2006 -0500
+++ b/mercurial/merge.py	Tue Oct 10 00:41:55 2006 -0500
@@ -210,7 +210,7 @@
                 a = ma.get(f, nullid)
                 # are both different from the ancestor?
                 if not overwrite and n != a and m2[f] != a:
-                    act("versions differ", "m", f, fmerge(f))
+                    act("versions differ", "m", f, f, f, fmerge(f), False)
                 # are we clobbering?
                 # is remote's version newer?
                 # or are we going back in time and clean?
@@ -226,14 +226,13 @@
         elif f in copy:
             f2 = copy[f]
             if f in ma: # case 3,20 A/B/A
-                act("remote moved", "c",
-                    f, f2, f2, fmerge(f, f2, f), True)
+                act("remote moved", "m", f, f2, f2, fmerge(f, f2, f), True)
             else:
                 if f2 in m1: # case 2 A,B/B/B
-                    act("local copied", "c",
+                    act("local copied", "m",
                         f, f2, f, fmerge(f, f2, f2), False)
                 else: # case 4,21 A/B/B
-                    act("local moved", "c",
+                    act("local moved", "m",
                         f, f2, f, fmerge(f, f2, f2), False)
         elif f in ma:
             if n != ma[f] and not overwrite:
@@ -258,7 +257,7 @@
             if f2 not in m2: # already seen
                 continue
             # rename case 1, A/A,B/A
-            act("remote copied", "c", f2, f, f, fmerge(f2, f, f2), False)
+            act("remote copied", "m", f2, f, f, fmerge(f2, f, f2), False)
         elif f in ma:
             if overwrite or backwards:
                 act("recreating", "g", f, m2.execf(f))
@@ -289,20 +288,16 @@
                     repo.ui.warn(_("update failed to remove %s: %s!\n") %
                                  (f, inst.strerror))
             removed +=1
-        elif m == "c": # copy
+        elif m == "m": # merge
             f2, fd, flag, move = a[2:]
-            repo.ui.status(_("merging %s and %s to %s\n") % (f, f2, fd))
+            if f != f2:
+                repo.ui.status(_("merging %s and %s to %s\n") % (f, f2, fd))
+            else:
+                repo.ui.status(_("merging %s\n") % f)
             if filemerge(repo, f, f2, fd, wctx, mctx, move):
                 unresolved += 1
             util.set_exec(repo.wjoin(fd), flag)
             merged += 1
-        elif m == "m": # merge
-            flag = a[2]
-            repo.ui.status(_("merging %s\n") % f)
-            if filemerge(repo, f, f, f, wctx, mctx, False):
-                unresolved += 1
-            util.set_exec(repo.wjoin(f), flag)
-            merged += 1
         elif m == "g": # get
             flag = a[2]
             repo.ui.note(_("getting %s\n") % f)
@@ -332,21 +327,6 @@
             else:
                 repo.dirstate.update([f], 'n')
         elif m == "m": # merge
-            flag = a[2]
-            if branchmerge:
-                # We've done a branch merge, mark this file as merged
-                # so that we properly record the merger later
-                repo.dirstate.update([f], 'm')
-            else:
-                # We've update-merged a locally modified file, so
-                # we set the dirstate to emulate a normal checkout
-                # of that file some time in the past. Thus our
-                # merge will appear as a normal local file
-                # modification.
-                fl = repo.file(f)
-                f_len = mctx.filectx(f).size()
-                repo.dirstate.update([f], 'n', st_size=f_len, st_mtime=-1)
-        elif m == "c": # copy
             f2, fd, flag, move = a[2:]
             if branchmerge:
                 # We've done a branch merge, mark this file as merged
@@ -358,15 +338,15 @@
                 # of that file some time in the past. Thus our
                 # merge will appear as a normal local file
                 # modification.
-                fl = repo.file(f)
                 f_len = mctx.filectx(f).size()
                 repo.dirstate.update([fd], 'n', st_size=f_len, st_mtime=-1)
-            if move:
-                repo.dirstate.update([f], 'r')
-            if f != fd:
-                repo.dirstate.copy(f, fd)
-            else:
-                repo.dirstate.copy(f2, fd)
+            if f != f2: # copy/rename
+                if move:
+                    repo.dirstate.update([f], 'r')
+                if f != fd:
+                    repo.dirstate.copy(f, fd)
+                else:
+                    repo.dirstate.copy(f2, fd)
 
 def update(repo, node, branchmerge=False, force=False, partial=None,
            wlock=None, show_stats=True, remind=True):
--- a/tests/test-rename-merge1.out	Tue Oct 10 00:32:30 2006 -0500
+++ b/tests/test-rename-merge1.out	Tue Oct 10 00:41:55 2006 -0500
@@ -4,7 +4,7 @@
 resolving manifests
  overwrite None branchmerge True partial False
  ancestor f26ec4fc3fa3 local 8e765a822af2 remote af1939970a1c
- a: remote moved -> c
+ a: remote moved -> m
  b2: remote created -> g
 merging a and b to b
 resolving a
--- a/tests/test-rename-merge2.out	Tue Oct 10 00:32:30 2006 -0500
+++ b/tests/test-rename-merge2.out	Tue Oct 10 00:41:55 2006 -0500
@@ -5,7 +5,7 @@
  overwrite None branchmerge True partial False
  ancestor e300d1c794ec local 735846fee2d7 remote 924404dff337
  rev: versions differ -> m
- a: remote copied -> c
+ a: remote copied -> m
 merging a and b to b
 resolving a
 my a@. other b@735846fee2d7 ancestor a@924404dff337
@@ -28,7 +28,7 @@
  overwrite None branchmerge True partial False
  ancestor ac809aeed39a local f4db7e329e71 remote 924404dff337
  a: remote is newer -> g
- b: local copied -> c
+ b: local copied -> m
  rev: versions differ -> m
 getting a
 merging b and a to b
@@ -51,7 +51,7 @@
 resolving manifests
  overwrite None branchmerge True partial False
  ancestor e300d1c794ec local e03727d2d66b remote 924404dff337
- a: remote moved -> c
+ a: remote moved -> m
  rev: versions differ -> m
 merging a and b to b
 resolving a
@@ -74,7 +74,7 @@
 resolving manifests
  overwrite None branchmerge True partial False
  ancestor ecf3cb2a4219 local f4db7e329e71 remote 924404dff337
- b: local moved -> c
+ b: local moved -> m
  rev: versions differ -> m
 merging b and a to b
 resolving b
@@ -96,7 +96,7 @@
  overwrite None branchmerge True partial False
  ancestor 94b33a1b7f2d local 735846fee2d7 remote 924404dff337
  rev: versions differ -> m
- a: remote copied -> c
+ a: remote copied -> m
 merging a and b to b
 resolving a
 my a@. other b@735846fee2d7 ancestor a@924404dff337
@@ -118,7 +118,7 @@
 resolving manifests
  overwrite None branchmerge True partial False
  ancestor ac809aeed39a local 97c705ade336 remote 924404dff337
- b: local copied -> c
+ b: local copied -> m
  rev: versions differ -> m
 merging b and a to b
 resolving b
@@ -140,7 +140,7 @@
 resolving manifests
  overwrite None branchmerge True partial False
  ancestor 94b33a1b7f2d local e03727d2d66b remote 924404dff337
- a: remote moved -> c
+ a: remote moved -> m
  rev: versions differ -> m
 merging a and b to b
 resolving a
@@ -163,7 +163,7 @@
 resolving manifests
  overwrite None branchmerge True partial False
  ancestor ecf3cb2a4219 local 97c705ade336 remote 924404dff337
- b: local moved -> c
+ b: local moved -> m
  rev: versions differ -> m
 merging b and a to b
 resolving b
@@ -399,7 +399,7 @@
 resolving manifests
  overwrite None branchmerge True partial False
  ancestor e300d1c794ec local 79cc6877a3b7 remote 924404dff337
- a: remote moved -> c
+ a: remote moved -> m
  rev: versions differ -> m
 merging a and b to b
 resolving a
@@ -422,7 +422,7 @@
 resolving manifests
  overwrite None branchmerge True partial False
  ancestor ec03c2ca8642 local f4db7e329e71 remote 924404dff337
- b: local moved -> c
+ b: local moved -> m
  rev: versions differ -> m
 merging b and a to b
 resolving b
@@ -443,7 +443,7 @@
 resolving manifests
  overwrite None branchmerge True partial False
  ancestor ecf3cb2a4219 local 2b958612230f remote 924404dff337
- b: local moved -> c
+ b: local moved -> m
  rev: versions differ -> m
  c: remote created -> g
 merging b and a to b