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.
--- a/mercurial/merge.py Sun Apr 06 13:39:51 2014 +0200
+++ b/mercurial/merge.py Mon Apr 07 02:12:28 2014 +0200
@@ -449,7 +449,7 @@
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 @@
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':
@@ -778,6 +778,8 @@
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)
--- a/tests/test-graft.t Sun Apr 06 13:39:51 2014 +0200
+++ b/tests/test-graft.t Mon Apr 07 02:12:28 2014 +0200
@@ -150,6 +150,7 @@
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 @@
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
--- a/tests/test-issue672.t Sun Apr 06 13:39:51 2014 +0200
+++ b/tests/test-issue672.t Mon Apr 07 02:12:28 2014 +0200
@@ -36,6 +36,7 @@
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
--- a/tests/test-rename-merge2.t Sun Apr 06 13:39:51 2014 +0200
+++ b/tests/test-rename-merge2.t Mon Apr 07 02:12:28 2014 +0200
@@ -86,6 +86,7 @@
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 @@
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