Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hg.py @ 42600:3bc400ccbf99
abort: added support for merge
This adds support of `hg merge --abort` to `hg abort` plan.
This involves refactoring `hg.merge` into two different
functions removing the abort logic of `merge` from `hg.merge`
and then creating a seperate `hg.abortmerge` to handle the
abort logic so that the abortion of merge can be called
independently.
`hg.abortmerge` is then registered as `abortfunc` for the
state detection API so that `commands.abort` can use it to
deal with an unfinished merge operation.
Results are shown as tests.
Differential Revision: https://phab.mercurial-scm.org/D6588
author | Taapas Agrawal <taapas2897@gmail.com> |
---|---|
date | Sun, 30 Jun 2019 01:07:14 +0530 |
parents | 57539e5ea2e0 |
children | 209f2b8a50dc |
line wrap: on
line diff
--- a/mercurial/hg.py Wed Jun 26 22:15:07 2019 +0530 +++ b/mercurial/hg.py Sun Jun 30 01:07:14 2019 +0530 @@ -956,31 +956,35 @@ abort=False): """Branch merge with node, resolving changes. Return true if any unresolved conflicts.""" - if not abort: - stats = mergemod.update(repo, node, branchmerge=True, force=force, - mergeforce=mergeforce, labels=labels) - else: - ms = mergemod.mergestate.read(repo) - if ms.active(): - # there were conflicts - node = ms.localctx.hex() - else: - # there were no conficts, mergestate was not stored - node = repo['.'].hex() + if abort: + return abortmerge(repo.ui, repo, labels=labels) - repo.ui.status(_("aborting the merge, updating back to" - " %s\n") % node[:12]) - stats = mergemod.update(repo, node, branchmerge=False, force=True, - labels=labels) - + stats = mergemod.update(repo, node, branchmerge=True, force=force, + mergeforce=mergeforce, labels=labels) _showstats(repo, stats) if stats.unresolvedcount: repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " "or 'hg merge --abort' to abandon\n")) - elif remind and not abort: + elif remind: repo.ui.status(_("(branch merge, don't forget to commit)\n")) return stats.unresolvedcount > 0 +def abortmerge(ui, repo, labels=None): + ms = mergemod.mergestate.read(repo) + if ms.active(): + # there were conflicts + node = ms.localctx.hex() + else: + # there were no conficts, mergestate was not stored + node = repo['.'].hex() + + repo.ui.status(_("aborting the merge, updating back to" + " %s\n") % node[:12]) + stats = mergemod.update(repo, node, branchmerge=False, force=True, + labels=labels) + _showstats(repo, stats) + return stats.unresolvedcount > 0 + def _incoming(displaychlist, subreporecurse, ui, repo, source, opts, buffered=False): """