# HG changeset patch # User Martin von Zweigbergk # Date 1417643428 28800 # Node ID 416c133145ee78c8e83865b7370e185eed69c1be # Parent 42ae1b1f048ffeeef02f29805a8c855bf9d33731 merge: extract _resolvetrivial() function We would eventually like to move the resolution of modify/delete and delete/modify conflicts to the resolve phase. However, we don't want to move the checks for identical content that were added in 902554884335 (merge: before cd/dc prompt, check that changed side really changed, 2014-12-01). Let's instead move these out to a new _resolvetrivial() function that processes the actions from manifestmerge() and replaces any false cd/dc conflicts. The function will also provide a natural place for us to later add code for resolving false 'm' conflicts. diff -r 42ae1b1f048f -r 416c133145ee mercurial/merge.py --- a/mercurial/merge.py Tue Dec 09 22:10:51 2014 -0800 +++ b/mercurial/merge.py Wed Dec 03 13:50:28 2014 -0800 @@ -537,6 +537,30 @@ return actions, diverge, renamedelete +def _resolvetrivial(repo, wctx, mctx, ancestor, actions): + """Resolves false conflicts where the nodeid changed but the content + remained the same.""" + + cdactions = [] + for action in actions['cd']: + f = action[0] + if f in ancestor and not wctx[f].cmp(ancestor[f]): + # local did change but ended up with same content + actions['r'].append((f, None, "prompt same")) + else: + cdactions.append(action) + actions['cd'] = cdactions + + dcactions = [] + for action in actions['dc']: + f = action[0] + if f in ancestor and not mctx[f].cmp(ancestor[f]): + # remote did change but ended up with same content + pass # don't get = keep local deleted + else: + dcactions.append(action) + actions['dc'] = dcactions + def calculateupdates(repo, wctx, mctx, ancestors, branchmerge, force, partial, acceptremote, followcopies): "Calculate the actions needed to merge mctx into wctx using ancestors" @@ -614,12 +638,11 @@ continue repo.ui.note(_('end of auction\n\n')) + _resolvetrivial(repo, wctx, mctx, ancestors[0], actions) + # Prompt and create actions. TODO: Move this towards resolve phase. for f, args, msg in sorted(actions['cd']): - if f in ancestors[0] and not wctx[f].cmp(ancestors[0][f]): - # local did change but ended up with same content - actions['r'].append((f, None, "prompt same")) - elif repo.ui.promptchoice( + if repo.ui.promptchoice( _("local changed %s which remote deleted\n" "use (c)hanged version or (d)elete?" "$$ &Changed $$ &Delete") % f, 0): @@ -630,10 +653,7 @@ for f, args, msg in sorted(actions['dc']): flags, = args - if f in ancestors[0] and not mctx[f].cmp(ancestors[0][f]): - # remote did change but ended up with same content - pass # don't get = keep local deleted - elif repo.ui.promptchoice( + if repo.ui.promptchoice( _("remote changed %s which local deleted\n" "use (c)hanged version or leave (d)eleted?" "$$ &Changed $$ &Deleted") % f, 0) == 0: