Mercurial > hg
changeset 28140:276644ae9e8d
destutil: allow to disable the "on head check" in destmerge
'hg merge' refuses to pick a default destination if the working copy is not on
a head. This is a very sensible default for 'hg merge' but 'hg rebase' should
work in this situation. So we introduce a way to disable this check. It will
soon be used by rebase.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 08 Feb 2016 22:58:15 +0000 |
parents | 5476a7a039c0 |
children | 13bb8de97f87 |
files | mercurial/destutil.py |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/destutil.py Mon Feb 08 19:32:29 2016 +0100 +++ b/mercurial/destutil.py Mon Feb 08 22:58:15 2016 +0000 @@ -216,7 +216,7 @@ assert node is not None return node -def _destmergebranch(repo, action='merge', sourceset=None): +def _destmergebranch(repo, action='merge', sourceset=None, onheadcheck=True): """find merge destination based on branch heads""" node = None @@ -235,7 +235,7 @@ branch = ctx.branch() bheads = repo.branchheads(branch) - if not repo.revs('%ld and %ln', sourceset, bheads): + if onheadcheck and not repo.revs('%ld and %ln', sourceset, bheads): # Case A: working copy if not on a head. (merge only) # # This is probably a user mistake We bailout pointing at 'hg update' @@ -275,7 +275,7 @@ assert node is not None return node -def destmerge(repo, action='merge', sourceset=None): +def destmerge(repo, action='merge', sourceset=None, onheadcheck=True): """return the default destination for a merge (or raise exception about why it can't pick one) @@ -285,7 +285,8 @@ if repo._activebookmark: node = _destmergebook(repo, action=action, sourceset=sourceset) else: - node = _destmergebranch(repo, action=action, sourceset=sourceset) + node = _destmergebranch(repo, action=action, sourceset=sourceset, + onheadcheck=onheadcheck) return repo[node].rev() histeditdefaultrevset = 'reverse(only(.) and not public() and not ::merge())'