changeset 20945:18adc15635a1

merge: keep destination filename as key in filemerge actions Gives more readable debug output and makes it possible to compare/merge actions later.
author Mads Kiilerich <madski@unity3d.com>
date Sun, 02 Mar 2014 18:52:16 +0100
parents 5b8d5803d7b7
children e910336539f7
files mercurial/merge.py tests/test-copy-move-merge.t tests/test-double-merge.t tests/test-graft.t tests/test-issue672.t tests/test-rebase-collapse.t tests/test-rename-merge1.t tests/test-rename-merge2.t
diffstat 8 files changed, 64 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Sun Mar 02 18:49:36 2014 +0100
+++ b/mercurial/merge.py	Sun Mar 02 18:52:16 2014 +0100
@@ -342,10 +342,10 @@
         f2, flags = args
         pmmf.add(f)
     def mergeop(f, args):
-        f2, fa, fd, move, anc = args
+        f1, f2, fa, move, anc = args
         if move:
-            pmmf.discard(f)
-        pmmf.add(fd)
+            pmmf.discard(f1)
+        pmmf.add(f)
 
     opmap = {
         "a": addop,
@@ -471,7 +471,7 @@
             elif nol and n1 == a: # local only changed 'x'
                 actions.append((f, "g", (fl1,), "remote is newer"))
             else: # both changed something
-                actions.append((f, "m", (f, fa, f, False, pa.node()),
+                actions.append((f, "m", (f, f, fa, False, pa.node()),
                                "versions differ"))
         elif f in copied: # files we'll deal with on m2 side
             pass
@@ -481,8 +481,8 @@
                             "remote directory rename - move from " + f))
         elif n1 and f in copy:
             f2 = copy[f]
-            actions.append((f, "m", (f2, f2, f, False, pa.node()),
-                            "local copied/moved to " + f2))
+            actions.append((f, "m", (f, f2, f2, False, pa.node()),
+                            "local copied/moved from " + f2))
         elif n1 and f in ma: # clean, a different, no remote
             if n1 != ma[f]:
                 if acceptremote:
@@ -500,11 +500,11 @@
         elif n2 and f in copy:
             f2 = copy[f]
             if f2 in m2:
-                actions.append((f2, "m", (f, f2, f, False, pa.node()),
-                                "remote copied to " + f))
+                actions.append((f, "m", (f2, f, f2, False, pa.node()),
+                                "remote copied from " + f2))
             else:
-                actions.append((f2, "m", (f, f2, f, True, pa.node()),
-                                "remote moved to " + f))
+                actions.append((f, "m", (f2, f, f2, True, pa.node()),
+                                "remote moved from " + f2))
         elif n2 and f not in ma:
             # local unknown, remote created: the logic is described by the
             # following table:
@@ -621,20 +621,20 @@
         f, m, args, msg = a
         repo.ui.debug(" %s: %s -> %s\n" % (f, msg, m))
         if m == "m": # merge
-            f2, fa, fd, move, anc = args
-            if fd == '.hgsubstate': # merged internally
+            f1, f2, fa, move, anc = args
+            if f == '.hgsubstate': # merged internally
                 continue
-            repo.ui.debug("  preserving %s for resolve of %s\n" % (f, fd))
-            fcl = wctx[f]
+            repo.ui.debug("  preserving %s for resolve of %s\n" % (f1, f))
+            fcl = wctx[f1]
             fco = mctx[f2]
             actx = repo[anc]
             if fa in actx:
                 fca = actx[fa]
             else:
-                fca = repo.filectx(f, fileid=nullrev)
-            ms.add(fcl, fco, fca, fd)
-            if f != fd and move:
-                moves.append(f)
+                fca = repo.filectx(f1, fileid=nullrev)
+            ms.add(fcl, fco, fca, f)
+            if f1 != f and move:
+                moves.append(f1)
 
     audit = repo.wopener.audit
 
@@ -682,13 +682,13 @@
         f, m, args, msg = a
         progress(_updating, z + i + 1, item=f, total=numupdates, unit=_files)
         if m == "m": # merge
-            f2, fa, fd, move, anc = args
-            if fd == '.hgsubstate': # subrepo states need updating
+            f1, f2, fa, move, anc = args
+            if f == '.hgsubstate': # subrepo states need updating
                 subrepo.submerge(repo, wctx, mctx, wctx.ancestor(mctx),
                                  overwrite)
                 continue
-            audit(fd)
-            r = ms.resolve(fd, wctx)
+            audit(f)
+            r = ms.resolve(f, wctx)
             if r is not None and r > 0:
                 unresolved += 1
             else:
@@ -793,28 +793,28 @@
             else:
                 repo.dirstate.normal(f)
         elif m == "m": # merge
-            f2, fa, fd, move, anc = args
+            f1, f2, fa, move, anc = args
             if branchmerge:
                 # We've done a branch merge, mark this file as merged
                 # so that we properly record the merger later
-                repo.dirstate.merge(fd)
-                if f != f2: # copy/rename
+                repo.dirstate.merge(f)
+                if f1 != f2: # copy/rename
                     if move:
-                        repo.dirstate.remove(f)
-                    if f != fd:
-                        repo.dirstate.copy(f, fd)
+                        repo.dirstate.remove(f1)
+                    if f1 != f:
+                        repo.dirstate.copy(f1, f)
                     else:
-                        repo.dirstate.copy(f2, fd)
+                        repo.dirstate.copy(f2, f)
             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.
-                if f2 == fd: # file not locally copied/moved
-                    repo.dirstate.normallookup(fd)
+                if f2 == f: # file not locally copied/moved
+                    repo.dirstate.normallookup(f)
                 if move:
-                    repo.dirstate.drop(f)
+                    repo.dirstate.drop(f1)
         elif m == "dm": # directory rename, move local
             f0, flag = args
             if f0 not in repo.dirstate:
--- a/tests/test-copy-move-merge.t	Sun Mar 02 18:49:36 2014 +0100
+++ b/tests/test-copy-move-merge.t	Sun Mar 02 18:52:16 2014 +0100
@@ -31,17 +31,17 @@
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: b8bf91eeebbc, local: add3f11052fa+, remote: 17c05bb7fcb6
-   a: remote moved to b -> m
+   b: remote moved from a -> m
     preserving a for resolve of b
-   a: remote moved to c -> m
+   c: remote moved from a -> m
     preserving a for resolve of c
   removing a
-  updating: a 1/2 files (50.00%)
+  updating: b 1/2 files (50.00%)
   picked tool 'internal:merge' for b (binary False symlink False)
   merging a and b to b
   my b@add3f11052fa+ other b@17c05bb7fcb6 ancestor a@b8bf91eeebbc
    premerge successful
-  updating: a 2/2 files (100.00%)
+  updating: c 2/2 files (100.00%)
   picked tool 'internal:merge' for c (binary False symlink False)
   merging a and c to c
   my c@add3f11052fa+ other c@17c05bb7fcb6 ancestor a@b8bf91eeebbc
--- a/tests/test-double-merge.t	Sun Mar 02 18:49:36 2014 +0100
+++ b/tests/test-double-merge.t	Sun Mar 02 18:52:16 2014 +0100
@@ -35,11 +35,11 @@
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: e6dc8efe11cc, local: 6a0df1dad128+, remote: 484bf6903104
-   foo: remote copied to bar -> m
+   bar: remote copied from foo -> m
     preserving foo for resolve of bar
    foo: versions differ -> m
     preserving foo for resolve of foo
-  updating: foo 1/2 files (50.00%)
+  updating: bar 1/2 files (50.00%)
   picked tool 'internal:merge' for bar (binary False symlink False)
   merging foo and bar to bar
   my bar@6a0df1dad128+ other bar@484bf6903104 ancestor foo@e6dc8efe11cc
--- a/tests/test-graft.t	Sun Mar 02 18:49:36 2014 +0100
+++ b/tests/test-graft.t	Sun Mar 02 18:52:16 2014 +0100
@@ -137,7 +137,7 @@
   resolving manifests
    branchmerge: True, force: True, partial: False
    ancestor: 68795b066622, local: ef0ef43d49e7+, remote: 5d205f8b35b6
-   b: local copied/moved to a -> m
+   b: local copied/moved from a -> m
     preserving b for resolve of b
   updating: b 1/1 files (100.00%)
   picked tool 'internal:merge' for b (binary False symlink False)
--- a/tests/test-issue672.t	Sun Mar 02 18:49:36 2014 +0100
+++ b/tests/test-issue672.t	Sun Mar 02 18:52:16 2014 +0100
@@ -65,7 +65,7 @@
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: c64f439569a9, local: e327dca35ac8+, remote: 746e9549ea96
-   1a: local copied/moved to 1 -> m
+   1a: local copied/moved from 1 -> m
     preserving 1a for resolve of 1a
   updating: 1a 1/1 files (100.00%)
   picked tool 'internal:merge' for 1a (binary False symlink False)
@@ -88,10 +88,10 @@
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: c64f439569a9, local: 746e9549ea96+, remote: e327dca35ac8
-   1: remote moved to 1a -> m
+   1a: remote moved from 1 -> m
     preserving 1 for resolve of 1a
   removing 1
-  updating: 1 1/1 files (100.00%)
+  updating: 1a 1/1 files (100.00%)
   picked tool 'internal:merge' for 1a (binary False symlink False)
   merging 1 and 1a to 1a
   my 1a@746e9549ea96+ other 1a@e327dca35ac8 ancestor 1@81f4b099af3d
--- a/tests/test-rebase-collapse.t	Sun Mar 02 18:49:36 2014 +0100
+++ b/tests/test-rebase-collapse.t	Sun Mar 02 18:52:16 2014 +0100
@@ -632,8 +632,8 @@
   merging a and d to d
   merging b and e to e
   merging c and f to f
+  merging f and c to c
   merging e and g to g
-  merging f and c to c
   saved backup bundle to $TESTTMP/copies/.hg/strip-backup/*-backup.hg (glob)
   $ hg st
   $ hg st --copies --change tip
--- a/tests/test-rename-merge1.t	Sun Mar 02 18:49:36 2014 +0100
+++ b/tests/test-rename-merge1.t	Sun Mar 02 18:52:16 2014 +0100
@@ -36,22 +36,22 @@
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: af1939970a1c, local: 044f8520aeeb+, remote: 85c198ef2f6c
-   a: remote moved to b -> m
+   a2: divergent renames -> dr
+   b: remote moved from a -> m
     preserving a for resolve of b
-   a2: divergent renames -> dr
    b2: remote created -> g
   removing a
   getting b2
   updating: b2 1/3 files (33.33%)
-  updating: a 2/3 files (66.67%)
+  updating: a2 2/3 files (66.67%)
+  note: possible conflict - a2 was renamed multiple times to:
+   c2
+   b2
+  updating: b 3/3 files (100.00%)
   picked tool 'internal:merge' for b (binary False symlink False)
   merging a and b to b
   my b@044f8520aeeb+ other b@85c198ef2f6c ancestor a@af1939970a1c
    premerge successful
-  updating: a2 3/3 files (100.00%)
-  note: possible conflict - a2 was renamed multiple times to:
-   c2
-   b2
   1 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
 
--- a/tests/test-rename-merge2.t	Sun Mar 02 18:49:36 2014 +0100
+++ b/tests/test-rename-merge2.t	Sun Mar 02 18:52:16 2014 +0100
@@ -86,11 +86,11 @@
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: 924404dff337, local: e300d1c794ec+, remote: 4ce40f5aca24
-   a: remote copied to b -> m
+   b: remote copied from a -> m
     preserving a for resolve of b
    rev: versions differ -> m
     preserving rev for resolve of rev
-  updating: a 1/2 files (50.00%)
+  updating: b 1/2 files (50.00%)
   picked tool 'python ../merge' for b (binary False symlink False)
   merging a and b to b
   my b@e300d1c794ec+ other b@4ce40f5aca24 ancestor a@924404dff337
@@ -122,7 +122,7 @@
    branchmerge: True, force: False, partial: False
    ancestor: 924404dff337, local: 86a2aa42fc76+, remote: f4db7e329e71
    a: remote is newer -> g
-   b: local copied/moved to a -> m
+   b: local copied/moved from a -> m
     preserving b for resolve of b
    rev: versions differ -> m
     preserving rev for resolve of rev
@@ -159,12 +159,12 @@
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: 924404dff337, local: e300d1c794ec+, remote: bdb19105162a
-   a: remote moved to b -> m
+   b: remote moved from a -> m
     preserving a for resolve of b
    rev: versions differ -> m
     preserving rev for resolve of rev
   removing a
-  updating: a 1/2 files (50.00%)
+  updating: b 1/2 files (50.00%)
   picked tool 'python ../merge' for b (binary False symlink False)
   merging a and b to b
   my b@e300d1c794ec+ other b@bdb19105162a ancestor a@924404dff337
@@ -194,7 +194,7 @@
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: 924404dff337, local: 02963e448370+, remote: f4db7e329e71
-   b: local copied/moved to a -> m
+   b: local copied/moved from a -> m
     preserving b for resolve of b
    rev: versions differ -> m
     preserving rev for resolve of rev
@@ -672,12 +672,12 @@
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: 924404dff337, local: e300d1c794ec+, remote: 49b6d8032493
-   a: remote moved to b -> m
+   b: remote moved from a -> m
     preserving a for resolve of b
    rev: versions differ -> m
     preserving rev for resolve of rev
   removing a
-  updating: a 1/2 files (50.00%)
+  updating: b 1/2 files (50.00%)
   picked tool 'python ../merge' for b (binary False symlink False)
   merging a and b to b
   my b@e300d1c794ec+ other b@49b6d8032493 ancestor a@924404dff337
@@ -706,7 +706,7 @@
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: 924404dff337, local: 62e7bf090eba+, remote: f4db7e329e71
-   b: local copied/moved to a -> m
+   b: local copied/moved from a -> m
     preserving b for resolve of b
    rev: versions differ -> m
     preserving rev for resolve of rev
@@ -744,7 +744,7 @@
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: 924404dff337, local: 02963e448370+, remote: 2b958612230f
-   b: local copied/moved to a -> m
+   b: local copied/moved from a -> m
     preserving b for resolve of b
    c: remote created -> g
    rev: versions differ -> m
@@ -842,15 +842,15 @@
     preserving 2/f for resolve of 2/f
    3/f: versions differ -> m
     preserving 3/f for resolve of 3/f
-   3/f: remote copied to 3/g -> m
+   3/g: remote copied from 3/f -> m
     preserving 3/f for resolve of 3/g
-   4/f: remote moved to 4/g -> m
+   4/g: remote moved from 4/f -> m
     preserving 4/f for resolve of 4/g
    5/f: versions differ -> m
     preserving 5/f for resolve of 5/f
-   5/g: local copied/moved to 5/f -> m
+   5/g: local copied/moved from 5/f -> m
     preserving 5/g for resolve of 5/g
-   6/g: local copied/moved to 6/f -> m
+   6/g: local copied/moved from 6/f -> m
     preserving 6/g for resolve of 6/g
    7/f: remote differs from untracked local -> m
     preserving 7/f for resolve of 7/f