mercurial/commands.py
changeset 14197 c124341c4cea
parent 14189 328422b0380d
child 14198 8f11fd321014
equal deleted inserted replaced
14196:e7483ec3c374 14197:c124341c4cea
  2923     if not node:
  2923     if not node:
  2924         branch = repo[None].branch()
  2924         branch = repo[None].branch()
  2925         bheads = repo.branchheads(branch)
  2925         bheads = repo.branchheads(branch)
  2926         if len(bheads) > 2:
  2926         if len(bheads) > 2:
  2927             raise util.Abort(_(
  2927             raise util.Abort(_(
  2928                 'branch \'%s\' has %d heads - '
  2928                 "branch '%s' has %d heads - "
  2929                 'please merge with an explicit rev\n'
  2929                 "please merge with an explicit rev\n"
  2930                 '(run \'hg heads .\' to see heads)')
  2930                 "(run 'hg heads .' to see heads)")
  2931                 % (branch, len(bheads)))
  2931                 % (branch, len(bheads)))
  2932 
  2932 
  2933         parent = repo.dirstate.p1()
  2933         parent = repo.dirstate.p1()
  2934         if len(bheads) == 1:
  2934         if len(bheads) == 1:
  2935             if len(repo.heads()) > 1:
  2935             if len(repo.heads()) > 1:
  2936                 raise util.Abort(_(
  2936                 raise util.Abort(_(
  2937                     'branch \'%s\' has one head - '
  2937                     "branch '%s' has one head - "
  2938                     'please merge with an explicit rev\n'
  2938                     "please merge with an explicit rev\n"
  2939                     '(run \'hg heads\' to see all heads)')
  2939                     "(run 'hg heads' to see all heads)")
  2940                     % branch)
  2940                     % branch)
  2941             msg = _('there is nothing to merge')
  2941             msg = _('there is nothing to merge')
  2942             if parent != repo.lookup(repo[None].branch()):
  2942             if parent != repo.lookup(repo[None].branch()):
  2943                 msg = _('%s - use "hg update" instead') % msg
  2943                 msg = _('%s - use "hg update" instead') % msg
  2944             raise util.Abort(msg)
  2944             raise util.Abort(msg)
  4082     names = [t.strip() for t in (name1,) + names]
  4082     names = [t.strip() for t in (name1,) + names]
  4083     if len(names) != len(set(names)):
  4083     if len(names) != len(set(names)):
  4084         raise util.Abort(_('tag names must be unique'))
  4084         raise util.Abort(_('tag names must be unique'))
  4085     for n in names:
  4085     for n in names:
  4086         if n in ['tip', '.', 'null']:
  4086         if n in ['tip', '.', 'null']:
  4087             raise util.Abort(_('the name \'%s\' is reserved') % n)
  4087             raise util.Abort(_("the name '%s' is reserved") % n)
  4088         if not n:
  4088         if not n:
  4089             raise util.Abort(_('tag names cannot consist entirely of whitespace'))
  4089             raise util.Abort(_('tag names cannot consist entirely of whitespace'))
  4090     if opts.get('rev') and opts.get('remove'):
  4090     if opts.get('rev') and opts.get('remove'):
  4091         raise util.Abort(_("--rev and --remove are incompatible"))
  4091         raise util.Abort(_("--rev and --remove are incompatible"))
  4092     if opts.get('rev'):
  4092     if opts.get('rev'):
  4094     message = opts.get('message')
  4094     message = opts.get('message')
  4095     if opts.get('remove'):
  4095     if opts.get('remove'):
  4096         expectedtype = opts.get('local') and 'local' or 'global'
  4096         expectedtype = opts.get('local') and 'local' or 'global'
  4097         for n in names:
  4097         for n in names:
  4098             if not repo.tagtype(n):
  4098             if not repo.tagtype(n):
  4099                 raise util.Abort(_('tag \'%s\' does not exist') % n)
  4099                 raise util.Abort(_("tag '%s' does not exist") % n)
  4100             if repo.tagtype(n) != expectedtype:
  4100             if repo.tagtype(n) != expectedtype:
  4101                 if expectedtype == 'global':
  4101                 if expectedtype == 'global':
  4102                     raise util.Abort(_('tag \'%s\' is not a global tag') % n)
  4102                     raise util.Abort(_("tag '%s' is not a global tag") % n)
  4103                 else:
  4103                 else:
  4104                     raise util.Abort(_('tag \'%s\' is not a local tag') % n)
  4104                     raise util.Abort(_("tag '%s' is not a local tag") % n)
  4105         rev_ = nullid
  4105         rev_ = nullid
  4106         if not message:
  4106         if not message:
  4107             # we don't translate commit messages
  4107             # we don't translate commit messages
  4108             message = 'Removed tag %s' % ', '.join(names)
  4108             message = 'Removed tag %s' % ', '.join(names)
  4109     elif not opts.get('force'):
  4109     elif not opts.get('force'):
  4110         for n in names:
  4110         for n in names:
  4111             if n in repo.tags():
  4111             if n in repo.tags():
  4112                 raise util.Abort(_('tag \'%s\' already exists '
  4112                 raise util.Abort(_("tag '%s' already exists "
  4113                                    '(use -f to force)') % n)
  4113                                    "(use -f to force)") % n)
  4114     if not opts.get('local'):
  4114     if not opts.get('local'):
  4115         p1, p2 = repo.dirstate.parents()
  4115         p1, p2 = repo.dirstate.parents()
  4116         if p2 != nullid:
  4116         if p2 != nullid:
  4117             raise util.Abort(_('uncommitted merge'))
  4117             raise util.Abort(_('uncommitted merge'))
  4118         bheads = repo.branchheads()
  4118         bheads = repo.branchheads()