Patchwork [11,of,16] merge: keep destination filename as key in filemerge actions

login
register
mail settings
Submitter Mads Kiilerich
Date March 2, 2014, 7:15 p.m.
Message ID <ee728599ef740d08cc0b.1393787744@localhost.localdomain>
Download mbox | patch
Permalink /patch/3823/
State Accepted
Commit 18adc15635a1a567a0a3c73c4f6d7897c117cee8
Headers show

Comments

Mads Kiilerich - March 2, 2014, 7:15 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1393782736 -3600
#      Sun Mar 02 18:52:16 2014 +0100
# Node ID ee728599ef740d08cc0b8f102d3dc6325f48120b
# Parent  6b0a190609ec080ff606f676bcebea54c89fc46f
merge: keep destination filename as key in filemerge actions

Gives more readable debug output and makes it possible to compare/merge actions
later.
Matt Mackall - April 4, 2014, 7:16 p.m.
On Sun, 2014-03-02 at 20:15 +0100, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1393782736 -3600
> #      Sun Mar 02 18:52:16 2014 +0100
> # Node ID ee728599ef740d08cc0b8f102d3dc6325f48120b
> # Parent  6b0a190609ec080ff606f676bcebea54c89fc46f
> merge: keep destination filename as key in filemerge actions

I've queued 9, 10, and 11, thanks.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -282,10 +282,10 @@  def _checkcollision(repo, wmf, actions):
         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,
@@ -411,7 +411,7 @@  def manifestmerge(repo, wctx, p2, pa, br
             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
@@ -421,8 +421,8 @@  def manifestmerge(repo, wctx, p2, pa, br
                             "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:
@@ -440,11 +440,11 @@  def manifestmerge(repo, wctx, p2, pa, br
         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:
@@ -561,20 +561,20 @@  def applyupdates(repo, actions, wctx, mc
         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
 
@@ -622,13 +622,13 @@  def applyupdates(repo, actions, wctx, mc
         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:
@@ -733,28 +733,28 @@  def recordupdates(repo, actions, branchm
             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:
diff --git a/tests/test-copy-move-merge.t b/tests/test-copy-move-merge.t
--- a/tests/test-copy-move-merge.t
+++ b/tests/test-copy-move-merge.t
@@ -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
diff --git a/tests/test-double-merge.t b/tests/test-double-merge.t
--- a/tests/test-double-merge.t
+++ b/tests/test-double-merge.t
@@ -35,11 +35,11 @@  we get conflicts that shouldn't be there
   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
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -137,7 +137,7 @@  Graft out of order, skipping a merge and
   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)
diff --git a/tests/test-issue672.t b/tests/test-issue672.t
--- a/tests/test-issue672.t
+++ b/tests/test-issue672.t
@@ -65,7 +65,7 @@  http://mercurial.selenic.com/bts/issue67
   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 @@  http://mercurial.selenic.com/bts/issue67
   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
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -607,8 +607,8 @@  Rebase, collapse and copies
   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
diff --git a/tests/test-rename-merge1.t b/tests/test-rename-merge1.t
--- a/tests/test-rename-merge1.t
+++ b/tests/test-rename-merge1.t
@@ -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)
 
diff --git a/tests/test-rename-merge2.t b/tests/test-rename-merge2.t
--- a/tests/test-rename-merge2.t
+++ b/tests/test-rename-merge2.t
@@ -86,11 +86,11 @@  args:
   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 @@  args:
    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 @@  args:
   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 @@  args:
   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 @@  m "um a c" "um x c" "      " "10 do merg
   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 @@  m "um a c" "um x c" "      " "10 do merg
   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 @@  m "nm a b" "um x a" "      " "22 get a, 
   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 @@  8  f  (f)  f   f   "remote differs from 
     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