mercurial/commands.py
changeset 6723 1fe6f365df2e
parent 6686 bb1575f74f27
child 6739 c9fbd6ec3489
equal deleted inserted replaced
6722:197d54d82f8d 6723:1fe6f365df2e
  1889     requested revision. Files that changed between either parent are
  1889     requested revision. Files that changed between either parent are
  1890     marked as changed for the next commit and a commit must be
  1890     marked as changed for the next commit and a commit must be
  1891     performed before any further updates are allowed.
  1891     performed before any further updates are allowed.
  1892 
  1892 
  1893     If no revision is specified, the working directory's parent is a
  1893     If no revision is specified, the working directory's parent is a
  1894     head revision, and the repository contains exactly one other head,
  1894     head revision, and the current branch contains exactly one other head,
  1895     the other head is merged with by default. Otherwise, an explicit
  1895     the other head is merged with by default. Otherwise, an explicit
  1896     revision to merge with must be provided.
  1896     revision to merge with must be provided.
  1897     """
  1897     """
  1898 
  1898 
  1899     if rev and node:
  1899     if rev and node:
  1900         raise util.Abort(_("please specify just one revision"))
  1900         raise util.Abort(_("please specify just one revision"))
  1901     if not node:
  1901     if not node:
  1902         node = rev
  1902         node = rev
  1903 
  1903 
  1904     if not node:
  1904     if not node:
  1905         heads = repo.heads()
  1905         branch = repo.workingctx().branch()
  1906         if len(heads) > 2:
  1906         bheads = repo.branchheads()
  1907             raise util.Abort(_('repo has %d heads - '
  1907         if len(bheads) > 2:
  1908                                'please merge with an explicit rev') %
  1908             raise util.Abort(_("branch '%s' has %d heads - "
  1909                              len(heads))
  1909                                "please merge with an explicit rev") %
       
  1910                              (branch, len(bheads)))
       
  1911 
  1910         parent = repo.dirstate.parents()[0]
  1912         parent = repo.dirstate.parents()[0]
  1911         if len(heads) == 1:
  1913         if len(bheads) == 1:
       
  1914             if len(repo.heads()) > 1:
       
  1915                 raise util.Abort(_("branch '%s' has one head - "
       
  1916                                    "please merge with an explicit rev") %
       
  1917                                  branch)
  1912             msg = _('there is nothing to merge')
  1918             msg = _('there is nothing to merge')
  1913             if parent != repo.lookup(repo.workingctx().branch()):
  1919             if parent != repo.lookup(repo.workingctx().branch()):
  1914                 msg = _('%s - use "hg update" instead') % msg
  1920                 msg = _('%s - use "hg update" instead') % msg
  1915             raise util.Abort(msg)
  1921             raise util.Abort(msg)
  1916 
  1922 
  1917         if parent not in heads:
  1923         if parent not in bheads:
  1918             raise util.Abort(_('working dir not at a head rev - '
  1924             raise util.Abort(_('working dir not at a head rev - '
  1919                                'use "hg update" or merge with an explicit rev'))
  1925                                'use "hg update" or merge with an explicit rev'))
  1920         node = parent == heads[0] and heads[-1] or heads[0]
  1926         node = parent == bheads[0] and bheads[-1] or bheads[0]
  1921     return hg.merge(repo, node, force=force)
  1927     return hg.merge(repo, node, force=force)
  1922 
  1928 
  1923 def outgoing(ui, repo, dest=None, **opts):
  1929 def outgoing(ui, repo, dest=None, **opts):
  1924     """show changesets not found in destination
  1930     """show changesets not found in destination
  1925 
  1931