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.
This commit is contained in:
Mads Kiilerich 2014-04-07 02:12:28 +02:00
parent 5a86bd87e5
commit 276e18adae
4 changed files with 10 additions and 3 deletions

View File

@ -449,7 +449,7 @@ def manifestmerge(repo, wctx, p2, pa, branchmerge, force, partial,
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, mctx, overwrite):
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 @@ def recordupdates(repo, actions, branchmerge):
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)

View File

@ -150,6 +150,7 @@ Graft out of order, skipping a merge and a duplicate
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 a duplicate
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

View File

@ -36,6 +36,7 @@ http://mercurial.selenic.com/bts/issue672
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

View File

@ -86,6 +86,7 @@ $4 = expected result
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 merge with no ancestor"
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