[PATCH 2 of 6] merge: let bid merge work on the file->action dict
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Thu Dec 18 18:12:18 CST 2014
On 12/17/2014 01:24 PM, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz at google.com>
> # Date 1418360213 28800
> # Thu Dec 11 20:56:53 2014 -0800
> # Node ID 3e68d3bbe0c72bd1eb9633c6a70e06291ed69309
> # Parent 7445d6d1d127f2e7b688071016f8a06663e946d9
> merge: let bid merge work on the file->action dict
I could use a bit more details here.
- is there anything special about bid merge? why does it needs its own
patch (assume ignorance over bid merge down here)
- why did the test changed?
>
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -525,12 +525,6 @@
> raise util.Abort(_("untracked files in working directory differ "
> "from files in requested revision"))
>
> - # Convert to dictionary-of-lists format
> - actionbyfile = actions
> - actions = dict((m, []) for m in 'a f g cd dc r dm dg m e k'.split())
> - for f, (m, args, msg) in actionbyfile.iteritems():
> - actions[m].append((f, args, msg))
> -
> return actions, diverge, renamedelete
>
> def _resolvetrivial(repo, wctx, mctx, ancestor, actions):
> @@ -583,22 +577,21 @@
> # Arbitrarily pick warnings from first iteration
> diverge = diverge1
> renamedelete = renamedelete1
> - for m, l in sorted(actions.items()):
> - for a in l:
> - f, args, msg = a
> - repo.ui.debug(' %s: %s -> %s\n' % (f, msg, m))
> - if f in fbids:
> - d = fbids[f]
> - if m in d:
> - d[m].append(a)
> - else:
> - d[m] = [a]
> + for f, a in sorted(actions.iteritems()):
> + m, args, msg = a
> + repo.ui.debug(' %s: %s -> %s\n' % (f, msg, m))
> + if f in fbids:
> + d = fbids[f]
> + if m in d:
> + d[m].append(a)
> else:
> - fbids[f] = {m: [a]}
> + d[m] = [a]
> + else:
> + fbids[f] = {m: [a]}
>
> # Pick the best bid for each file
> repo.ui.note(_('\nauction for merging merge bids\n'))
> - actions = dict((m, []) for m in actions.keys())
> + actions = {}
> for f, bids in sorted(fbids.items()):
> # bids is a mapping from action method to list af actions
> # Consensus?
> @@ -606,19 +599,19 @@
> m, l = bids.items()[0]
> if util.all(a == l[0] for a in l[1:]): # len(bids) is > 1
> repo.ui.note(" %s: consensus for %s\n" % (f, m))
> - actions[m].append(l[0])
> + actions[f] = l[0]
> continue
> # If keep is an option, just do it.
> if 'k' in bids:
> repo.ui.note(" %s: picking 'keep' action\n" % f)
> - actions['k'].append(bids['k'][0])
> + actions[f] = bids['k'][0]
> continue
> # If there are gets and they all agree [how could they not?], do it.
> if 'g' in bids:
> ga0 = bids['g'][0]
> if util.all(a == ga0 for a in bids['g'][1:]):
> repo.ui.note(" %s: picking 'get' action\n" % f)
> - actions['g'].append(ga0)
> + actions[f] = ga0
> continue
> # TODO: Consider other simple actions such as mode changes
> # Handle inefficient democrazy.
> @@ -630,10 +623,16 @@
> m, l = bids.items()[0]
> repo.ui.warn(_(' %s: ambiguous merge - picked %s action\n') %
> (f, m))
> - actions[m].append(l[0])
> + actions[f] = l[0]
> continue
> repo.ui.note(_('end of auction\n\n'))
>
> + # Convert to dictionary-of-lists format
> + actionbyfile = actions
> + actions = dict((m, []) for m in 'a f g cd dc r dm dg m e k'.split())
> + for f, (m, args, msg) in actionbyfile.iteritems():
> + actions[m].append((f, args, msg))
> +
> _resolvetrivial(repo, wctx, mctx, ancestors[0], actions)
>
> if wctx.rev() is None:
> diff --git a/tests/test-merge-criss-cross.t b/tests/test-merge-criss-cross.t
> --- a/tests/test-merge-criss-cross.t
> +++ b/tests/test-merge-criss-cross.t
> @@ -141,8 +141,8 @@
> resolving manifests
> branchmerge: True, force: False, partial: False
> ancestor: 40663881a6dd, local: 3b08d01b0ab5+, remote: adfe50279922
> + f1: versions differ -> m
> f2: remote unchanged -> k
> - f1: versions differ -> m
>
> auction for merging merge bids
> f1: picking 'get' action
> @@ -184,8 +184,8 @@
> resolving manifests
> branchmerge: True, force: False, partial: False
> ancestor: 40663881a6dd, local: adfe50279922+, remote: 3b08d01b0ab5
> + f1: versions differ -> m
> f2: remote is newer -> g
> - f1: versions differ -> m
>
> auction for merging merge bids
> f1: picking 'keep' action
> @@ -249,8 +249,8 @@
> resolving manifests
> branchmerge: True, force: False, partial: False
> ancestor: 40663881a6dd, local: 3b08d01b0ab5+, remote: adfe50279922
> + f1: versions differ -> m
> f2: remote unchanged -> k
> - f1: versions differ -> m
>
> auction for merging merge bids
> f1: picking 'get' action
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list