Patchwork [5,of,6,bid,merge,v2] merge: let manifestmerge emit 'keep' actions when keeping wd version

login
register
mail settings
Submitter Mads Kiilerich
Date April 7, 2014, 12:19 a.m.
Message ID <b8eaf05d1ce2dcacbfcf.1396829941@localhost.localdomain>
Download mbox | patch
Permalink /patch/4270/
State Accepted
Commit 0d67fccc0d43c1b622ddc1b11e8d416d81fc9ea9
Headers show

Comments

Mads Kiilerich - April 7, 2014, 12:19 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1396829548 -7200
#      Mon Apr 07 02:12:28 2014 +0200
# Node ID b8eaf05d1ce2dcacbfcf0168053568cd539f561c
# Parent  1cd8e01c37a5fff8a64898f6dc52df5dd332d5ac
merge: let manifestmerge emit 'keep' actions when keeping wd version

Such a 'keep' action will later be the preferred (non)action when there
is multiple ancestors. It is thus very convenient to have it explicitly.

The extra actions will only be emitted in the case where the local file has
changed since the ancestor but the other hasn't. That is the symmetrical
operation to a 'get' action.

This will create more action tuples that not really serve a purpose. The number
of actions will however have the number of changed files as upper bound and it
should thus not increase the memory/cpu use significantly.
Matt Mackall - April 17, 2014, 3:10 p.m.
On Mon, 2014-04-07 at 02:19 +0200, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1396829548 -7200
> #      Mon Apr 07 02:12:28 2014 +0200
> # Node ID b8eaf05d1ce2dcacbfcf0168053568cd539f561c
> # Parent  1cd8e01c37a5fff8a64898f6dc52df5dd332d5ac
> merge: let manifestmerge emit 'keep' actions when keeping wd version

I've queued patches 2, 3, and 5 here, thanks.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -449,7 +449,7 @@  def manifestmerge(repo, wctx, p2, pa, br
             fla = ma.flags(fa)
             nol = 'l' not in fl1 + fl2 + fla
             if n2 == a and fl2 == fla:
-                pass # remote unchanged - keep local
+                actions.append((f, "k", (), "keep")) # remote unchanged
             elif n1 == a and fl1 == fla: # local unchanged - use remote
                 if n1 == n2: # optimization: keep local content
                     actions.append((f, "e", (fl2,), "update permissions"))
@@ -634,13 +634,13 @@  def applyupdates(repo, actions, wctx, mc
             audit(f)
             util.unlinkpath(repo.wjoin(f))
 
-    numupdates = len(actions)
+    numupdates = len([a for a in actions if a[1] != 'k'])
     workeractions = [a for a in actions if a[1] in 'gr']
     updateactions = [a for a in workeractions if a[1] == 'g']
     updated = len(updateactions)
     removeactions = [a for a in workeractions if a[1] == 'r']
     removed = len(removeactions)
-    actions = [a for a in actions if a[1] not in 'gr']
+    actions = [a for a in actions if a[1] not in 'grk']
 
     hgsub = [a[1] for a in workeractions if a[0] == '.hgsubstate']
     if hgsub and hgsub[0] == 'r':
@@ -781,6 +781,8 @@  def recordupdates(repo, actions, branchm
             repo.dirstate.drop(f)
         elif m == "e": # exec change
             repo.dirstate.normallookup(f)
+        elif m == "k": # keep
+            pass
         elif m == "g": # get
             if branchmerge:
                 repo.dirstate.otherparent(f)
diff --git a/tests/test-graft.t b/tests/test-graft.t
--- a/tests/test-graft.t
+++ b/tests/test-graft.t
@@ -150,6 +150,7 @@  Graft out of order, skipping a merge and
   resolving manifests
    branchmerge: True, force: True, partial: False
    ancestor: 4c60f11aa304, local: 6b9e5368ca4e+, remote: 97f8bfe72746
+   b: keep -> k
    e: remote is newer -> g
   getting e
   updating: e 1/1 files (100.00%)
@@ -159,6 +160,7 @@  Graft out of order, skipping a merge and
   resolving manifests
    branchmerge: True, force: True, partial: False
    ancestor: 4c60f11aa304, local: 1905859650ec+, remote: 9c233e8e184d
+   b: keep -> k
    d: remote is newer -> g
    e: versions differ -> m
     preserving e for resolve of e
diff --git a/tests/test-issue672.t b/tests/test-issue672.t
--- a/tests/test-issue672.t
+++ b/tests/test-issue672.t
@@ -36,6 +36,7 @@  http://mercurial.selenic.com/bts/issue67
    ancestor: 81f4b099af3d, local: c64f439569a9+, remote: c12dcd37c90a
    1: other deleted -> r
    1a: remote created -> g
+   2: keep -> k
   removing 1
   updating: 1 1/2 files (50.00%)
   getting 1a
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,6 +86,7 @@  args:
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: 924404dff337, local: e300d1c794ec+, remote: 4ce40f5aca24
+   a: keep -> k
    b: remote copied from a -> m
     preserving a for resolve of b
    rev: versions differ -> m
@@ -570,6 +571,7 @@  m "um a c" "um x c" "      " "10 do merg
   resolving manifests
    branchmerge: True, force: False, partial: False
    ancestor: 924404dff337, local: 0b76e65c8289+, remote: 4ce40f5aca24
+   a: keep -> k
    b: versions differ -> m
     preserving b for resolve of b
    rev: versions differ -> m