mercurial/commands.py
changeset 17791 1e30c1bbd8c0
parent 17790 0291e122fb05
child 17806 dc7010ed0101
equal deleted inserted replaced
17790:0291e122fb05 17791:1e30c1bbd8c0
   811         raise util.Abort(_("--delete and --rename are incompatible"))
   811         raise util.Abort(_("--delete and --rename are incompatible"))
   812     if delete and rev:
   812     if delete and rev:
   813         raise util.Abort(_("--rev is incompatible with --delete"))
   813         raise util.Abort(_("--rev is incompatible with --delete"))
   814     if rename and rev:
   814     if rename and rev:
   815         raise util.Abort(_("--rev is incompatible with --rename"))
   815         raise util.Abort(_("--rev is incompatible with --rename"))
       
   816     if mark is None and (delete or rev):
       
   817         raise util.Abort(_("bookmark name required"))
   816 
   818 
   817     if delete:
   819     if delete:
   818         if mark is None:
       
   819             raise util.Abort(_("bookmark name required"))
       
   820         if mark not in marks:
   820         if mark not in marks:
   821             raise util.Abort(_("bookmark '%s' does not exist") % mark)
   821             raise util.Abort(_("bookmark '%s' does not exist") % mark)
   822         if mark == repo._bookmarkcurrent:
   822         if mark == repo._bookmarkcurrent:
   823             bookmarks.setcurrent(repo, None)
   823             bookmarks.setcurrent(repo, None)
   824         del marks[mark]
   824         del marks[mark]
   825         bookmarks.write(repo)
   825         bookmarks.write(repo)
   826         return
   826 
   827 
   827     elif rename:
   828     if rename:
       
   829         if mark is None:
   828         if mark is None:
   830             raise util.Abort(_("new bookmark name required"))
   829             raise util.Abort(_("new bookmark name required"))
   831         mark = checkformat(mark)
   830         mark = checkformat(mark)
   832         if rename not in marks:
   831         if rename not in marks:
   833             raise util.Abort(_("bookmark '%s' does not exist") % rename)
   832             raise util.Abort(_("bookmark '%s' does not exist") % rename)
   835         marks[mark] = marks[rename]
   834         marks[mark] = marks[rename]
   836         if repo._bookmarkcurrent == rename and not inactive:
   835         if repo._bookmarkcurrent == rename and not inactive:
   837             bookmarks.setcurrent(repo, mark)
   836             bookmarks.setcurrent(repo, mark)
   838         del marks[rename]
   837         del marks[rename]
   839         bookmarks.write(repo)
   838         bookmarks.write(repo)
   840         return
   839 
   841 
   840     elif mark is not None:
   842     if mark is not None:
       
   843         mark = checkformat(mark)
   841         mark = checkformat(mark)
   844         if inactive and mark == repo._bookmarkcurrent:
   842         if inactive and mark == repo._bookmarkcurrent:
   845             bookmarks.setcurrent(repo, None)
   843             bookmarks.setcurrent(repo, None)
   846             return
   844             return
   847         checkconflict(repo, mark, force)
   845         checkconflict(repo, mark, force)
   852         if not inactive and cur == marks[mark]:
   850         if not inactive and cur == marks[mark]:
   853             bookmarks.setcurrent(repo, mark)
   851             bookmarks.setcurrent(repo, mark)
   854         bookmarks.write(repo)
   852         bookmarks.write(repo)
   855         return
   853         return
   856 
   854 
   857     if mark is None:
   855     else: # mark is None
   858         if rev:
       
   859             raise util.Abort(_("bookmark name required"))
       
   860         if len(marks) == 0:
   856         if len(marks) == 0:
   861             ui.status(_("no bookmarks set\n"))
   857             ui.status(_("no bookmarks set\n"))
   862         if inactive:
   858         elif inactive:
   863             if not repo._bookmarkcurrent:
   859             if not repo._bookmarkcurrent:
   864                 ui.status(_("no active bookmark\n"))
   860                 ui.status(_("no active bookmark\n"))
   865             else:
   861             else:
   866                 bookmarks.setcurrent(repo, None)
   862                 bookmarks.setcurrent(repo, None)
   867             return
       
   868         else:
   863         else:
   869             for bmark, n in sorted(marks.iteritems()):
   864             for bmark, n in sorted(marks.iteritems()):
   870                 current = repo._bookmarkcurrent
   865                 current = repo._bookmarkcurrent
   871                 if bmark == current and n == cur:
   866                 if bmark == current and n == cur:
   872                     prefix, label = '*', 'bookmarks.current'
   867                     prefix, label = '*', 'bookmarks.current'
   877                     ui.write("%s\n" % bmark, label=label)
   872                     ui.write("%s\n" % bmark, label=label)
   878                 else:
   873                 else:
   879                     ui.write(" %s %-25s %d:%s\n" % (
   874                     ui.write(" %s %-25s %d:%s\n" % (
   880                         prefix, bmark, repo.changelog.rev(n), hexfn(n)),
   875                         prefix, bmark, repo.changelog.rev(n), hexfn(n)),
   881                         label=label)
   876                         label=label)
   882         return
       
   883 
   877 
   884 @command('branch',
   878 @command('branch',
   885     [('f', 'force', None,
   879     [('f', 'force', None,
   886      _('set branch name even if it shadows an existing branch')),
   880      _('set branch name even if it shadows an existing branch')),
   887     ('C', 'clean', None, _('reset branch name to parent branch name'))],
   881     ('C', 'clean', None, _('reset branch name to parent branch name'))],