diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -452,7 +452,8 @@ def overridecheckunknownfile(origfn, rep # writing the files into the working copy and lfcommands.updatelfiles # will update the largefiles. def overridecalculateupdates(origfn, repo, p1, p2, pas, branchmerge, force, - acceptremote, followcopies, matcher=None): + acceptremote, followcopies, matcher=None, + mergeforce=False): overwrite = force and not branchmerge actions, diverge, renamedelete = origfn( repo, p1, p2, pas, branchmerge, force, acceptremote, diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -5242,7 +5242,8 @@ def merge(ui, repo, node=None, **opts): try: # ui.forcemerge is an internal variable, do not document repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge') - return hg.merge(repo, node, force=opts.get('force')) + force = opts.get('force') + return hg.merge(repo, node, force=force, mergeforce=force) finally: ui.setconfig('ui', 'forcemerge', '', 'merge') diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -671,10 +671,10 @@ def clean(repo, node, show_stats=True, q _showstats(repo, stats, quietempty) return stats[3] > 0 -def merge(repo, node, force=None, remind=True): +def merge(repo, node, force=None, remind=True, mergeforce=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" - stats = mergemod.update(repo, node, True, force) + stats = mergemod.update(repo, node, True, force, mergeforce=mergeforce) _showstats(repo, stats) if stats[3]: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -603,7 +603,7 @@ def _checkunknownfile(repo, wctx, mctx, and repo.dirstate.normalize(f) not in repo.dirstate and mctx[f2].cmp(wctx[f])) -def _checkunknownfiles(repo, wctx, mctx, force, actions): +def _checkunknownfiles(repo, wctx, mctx, force, actions, mergeforce): """ Considers any actions that care about the presence of conflicting unknown files. For some actions, the result is to abort; for others, it is to @@ -905,13 +905,14 @@ def _resolvetrivial(repo, wctx, mctx, an del actions[f] # don't get = keep local deleted def calculateupdates(repo, wctx, mctx, ancestors, branchmerge, force, - acceptremote, followcopies, matcher=None): + acceptremote, followcopies, matcher=None, + mergeforce=False): "Calculate the actions needed to merge mctx into wctx using ancestors" if len(ancestors) == 1: # default actions, diverge, renamedelete = manifestmerge( repo, wctx, mctx, ancestors[0], branchmerge, force, matcher, acceptremote, followcopies) - _checkunknownfiles(repo, wctx, mctx, force, actions) + _checkunknownfiles(repo, wctx, mctx, force, actions, mergeforce) else: # only when merge.preferancestor=* - the default repo.ui.note( @@ -926,7 +927,7 @@ def calculateupdates(repo, wctx, mctx, a actions, diverge1, renamedelete1 = manifestmerge( repo, wctx, mctx, ancestor, branchmerge, force, matcher, acceptremote, followcopies) - _checkunknownfiles(repo, wctx, mctx, force, actions) + _checkunknownfiles(repo, wctx, mctx, force, actions, mergeforce) # Track the shortest set of warning on the theory that bid # merge will correctly incorporate more information @@ -1344,7 +1345,7 @@ def recordupdates(repo, actions, branchm repo.dirstate.normal(f) def update(repo, node, branchmerge, force, ancestor=None, - mergeancestor=False, labels=None, matcher=None): + mergeancestor=False, labels=None, matcher=None, mergeforce=False): """ Perform a merge between the working directory and the given node @@ -1358,6 +1359,8 @@ def update(repo, node, branchmerge, forc between different named branches. This flag is used by rebase extension as a temporary fix and should be avoided in general. labels = labels to use for base, local and other + mergeforce = whether the merge was run with 'merge --force' (deprecated): if + this is True, then 'force' should be True as well. The table below shows all the behaviors of the update command given the -c and -C or no options, whether the working directory @@ -1493,7 +1496,7 @@ def update(repo, node, branchmerge, forc ### calculate phase actionbyfile, diverge, renamedelete = calculateupdates( repo, wc, p2, pas, branchmerge, force, mergeancestor, - followcopies, matcher=matcher) + followcopies, matcher=matcher, mergeforce=mergeforce) # Prompt and create actions. Most of this is in the resolve phase # already, but we can't handle .hgsubstate in filemerge or