mercurial/commands.py
changeset 42542 2e1d9414ff71
parent 42541 3de4f17f4824
child 42560 70f1a84d0794
equal deleted inserted replaced
42541:3de4f17f4824 42542:2e1d9414ff71
  1582     ('', 'close-branch', None,
  1582     ('', 'close-branch', None,
  1583      _('mark a branch head as closed')),
  1583      _('mark a branch head as closed')),
  1584     ('', 'amend', None, _('amend the parent of the working directory')),
  1584     ('', 'amend', None, _('amend the parent of the working directory')),
  1585     ('s', 'secret', None, _('use the secret phase for committing')),
  1585     ('s', 'secret', None, _('use the secret phase for committing')),
  1586     ('e', 'edit', None, _('invoke editor on commit messages')),
  1586     ('e', 'edit', None, _('invoke editor on commit messages')),
       
  1587     ('', 'force-close-branch', None,
       
  1588      _('forcibly close branch from a non-head changeset (ADVANCED)')),
  1587     ('i', 'interactive', None, _('use interactive mode')),
  1589     ('i', 'interactive', None, _('use interactive mode')),
  1588     ] + walkopts + commitopts + commitopts2 + subrepoopts,
  1590     ] + walkopts + commitopts + commitopts2 + subrepoopts,
  1589     _('[OPTION]... [FILE]...'),
  1591     _('[OPTION]... [FILE]...'),
  1590     helpcategory=command.CATEGORY_COMMITTING, helpbasic=True,
  1592     helpcategory=command.CATEGORY_COMMITTING, helpbasic=True,
  1591     inferrepo=True)
  1593     inferrepo=True)
  1669 
  1671 
  1670     branch = repo[None].branch()
  1672     branch = repo[None].branch()
  1671     bheads = repo.branchheads(branch)
  1673     bheads = repo.branchheads(branch)
  1672 
  1674 
  1673     extra = {}
  1675     extra = {}
  1674     if opts.get('close_branch'):
  1676     if opts.get('close_branch') or opts.get('force_close_branch'):
  1675         extra['close'] = '1'
  1677         extra['close'] = '1'
  1676 
  1678 
  1677         if repo['.'].closesbranch():
  1679         if repo['.'].closesbranch():
  1678             raise error.Abort(_('current revision is already a branch closing'
  1680             raise error.Abort(_('current revision is already a branch closing'
  1679                                 ' head'))
  1681                                 ' head'))
  1680         elif not bheads:
  1682         elif not bheads:
  1681             raise error.Abort(_('branch "%s" has no heads to close') % branch)
  1683             raise error.Abort(_('branch "%s" has no heads to close') % branch)
  1682         elif branch == repo['.'].branch() and repo['.'].node() not in bheads:
  1684         elif (branch == repo['.'].branch() and repo['.'].node() not in bheads
  1683             raise error.Abort(_('can only close branch heads'))
  1685               and not opts.get('force_close_branch')):
       
  1686             hint = _('use --force-close-branch to close branch from a non-head'
       
  1687                      ' changeset')
       
  1688             raise error.Abort(_('can only close branch heads'), hint=hint)
  1684         elif opts.get('amend'):
  1689         elif opts.get('amend'):
  1685             if (repo['.'].p1().branch() != branch and
  1690             if (repo['.'].p1().branch() != branch and
  1686                 repo['.'].p2().branch() != branch):
  1691                 repo['.'].p2().branch() != branch):
  1687                 raise error.Abort(_('can only close branch heads'))
  1692                 raise error.Abort(_('can only close branch heads'))
  1688 
  1693