Mercurial > public > mercurial-scm > hg
diff mercurial/commands.py @ 2915:013921c753bd
merge with other head by default, not tip.
fixes issue 339.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Tue, 15 Aug 2006 11:38:07 -0700 |
parents | 02e239bbd7f9 |
children | b70740aefa4d |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Aug 15 09:37:58 2006 -0700 +++ b/mercurial/commands.py Tue Aug 15 11:38:07 2006 -0700 @@ -1969,9 +1969,29 @@ requested revision. Files that changed between either parent are marked as changed for the next commit and a commit must be performed before any further updates are allowed. + + If no revision is specified, the working directory's parent is a + head revision, and the repository contains exactly one other head, + the other head is merged with by default. Otherwise, an explicit + revision to merge with must be provided. """ - node = _lookup(repo, node, branch) + if node: + node = _lookup(repo, node, branch) + else: + heads = repo.heads() + if len(heads) > 2: + raise util.Abort(_('repo has %d heads - ' + 'please merge with an explicit rev') % + len(heads)) + if len(heads) == 1: + raise util.Abort(_('there is nothing to merge - ' + 'use "hg update" instead')) + parent = repo.dirstate.parents()[0] + if parent not in heads: + raise util.Abort(_('working dir not at a head rev - ' + 'use "hg update" or merge with an explicit rev')) + node = parent == heads[0] and heads[-1] or heads[0] return hg.merge(repo, node, force=force) def outgoing(ui, repo, dest=None, **opts):