mercurial/commands.py
changeset 20233 410193f11422
parent 20232 5fe4c1a9dc34
child 20234 8a133190da89
equal deleted inserted replaced
20232:5fe4c1a9dc34 20233:410193f11422
   816             raise util.Abort(_("bookmark names cannot consist entirely of "
   816             raise util.Abort(_("bookmark names cannot consist entirely of "
   817                                "whitespace"))
   817                                "whitespace"))
   818         scmutil.checknewlabel(repo, mark, 'bookmark')
   818         scmutil.checknewlabel(repo, mark, 'bookmark')
   819         return mark
   819         return mark
   820 
   820 
   821     def checkconflict(repo, mark, force=False, target=None):
   821     def checkconflict(repo, mark, cur, force=False, target=None):
   822         if mark in marks and not force:
   822         if mark in marks and not force:
   823             if target:
   823             if target:
   824                 if marks[mark] == target and target == cur:
   824                 if marks[mark] == target and target == cur:
   825                     # re-activating a bookmark
   825                     # re-activating a bookmark
   826                     return
   826                     return
   881                 elif len(names) > 1:
   881                 elif len(names) > 1:
   882                     raise util.Abort(_("only one new bookmark name allowed"))
   882                     raise util.Abort(_("only one new bookmark name allowed"))
   883                 mark = checkformat(names[0])
   883                 mark = checkformat(names[0])
   884                 if rename not in marks:
   884                 if rename not in marks:
   885                     raise util.Abort(_("bookmark '%s' does not exist") % rename)
   885                     raise util.Abort(_("bookmark '%s' does not exist") % rename)
   886                 checkconflict(repo, mark, force)
   886                 checkconflict(repo, mark, cur, force)
   887                 marks[mark] = marks[rename]
   887                 marks[mark] = marks[rename]
   888                 if repo._bookmarkcurrent == rename and not inactive:
   888                 if repo._bookmarkcurrent == rename and not inactive:
   889                     bookmarks.setcurrent(repo, mark)
   889                     bookmarks.setcurrent(repo, mark)
   890                 del marks[rename]
   890                 del marks[rename]
   891                 marks.write()
   891                 marks.write()
   900                         bookmarks.unsetcurrent(repo)
   900                         bookmarks.unsetcurrent(repo)
   901                         return
   901                         return
   902                     tgt = cur
   902                     tgt = cur
   903                     if rev:
   903                     if rev:
   904                         tgt = scmutil.revsingle(repo, rev).node()
   904                         tgt = scmutil.revsingle(repo, rev).node()
   905                     checkconflict(repo, mark, force, tgt)
   905                     checkconflict(repo, mark, cur, force, tgt)
   906                     marks[mark] = tgt
   906                     marks[mark] = tgt
   907                 if not inactive and cur == marks[newact] and not rev:
   907                 if not inactive and cur == marks[newact] and not rev:
   908                     bookmarks.setcurrent(repo, newact)
   908                     bookmarks.setcurrent(repo, newact)
   909                 elif cur != tgt and newact == repo._bookmarkcurrent:
   909                 elif cur != tgt and newact == repo._bookmarkcurrent:
   910                     bookmarks.unsetcurrent(repo)
   910                     bookmarks.unsetcurrent(repo)