mercurial/commands.py
changeset 18777 8048c519dc6a
parent 18776 87441497ecaa
parent 18773 56dd55da2f7d
child 18783 b99e62a9b7a2
equal deleted inserted replaced
18776:87441497ecaa 18777:8048c519dc6a
   806             raise util.Abort(_("bookmark names cannot consist entirely of "
   806             raise util.Abort(_("bookmark names cannot consist entirely of "
   807                                "whitespace"))
   807                                "whitespace"))
   808         scmutil.checknewlabel(repo, mark, 'bookmark')
   808         scmutil.checknewlabel(repo, mark, 'bookmark')
   809         return mark
   809         return mark
   810 
   810 
   811     def checkconflict(repo, mark, force=False):
   811     def checkconflict(repo, mark, force=False, target=None):
   812         if mark in marks and not force:
   812         if mark in marks and not force:
       
   813             if target:
       
   814                 anc = repo.changelog.ancestors([repo[target].rev()])
       
   815                 bmctx = repo[marks[mark]]
       
   816                 if bmctx.rev() in anc:
       
   817                     ui.status(_("moving bookmark '%s' forward from %s\n") %
       
   818                               (mark, short(bmctx.node())))
       
   819                     return
   813             raise util.Abort(_("bookmark '%s' already exists "
   820             raise util.Abort(_("bookmark '%s' already exists "
   814                                "(use -f to force)") % mark)
   821                                "(use -f to force)") % mark)
   815         if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
   822         if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
   816             and not force):
   823             and not force):
   817             raise util.Abort(
   824             raise util.Abort(
   850     elif mark is not None:
   857     elif mark is not None:
   851         mark = checkformat(mark)
   858         mark = checkformat(mark)
   852         if inactive and mark == repo._bookmarkcurrent:
   859         if inactive and mark == repo._bookmarkcurrent:
   853             bookmarks.setcurrent(repo, None)
   860             bookmarks.setcurrent(repo, None)
   854             return
   861             return
   855         checkconflict(repo, mark, force)
   862         tgt = cur
   856         if rev:
   863         if rev:
   857             marks[mark] = scmutil.revsingle(repo, rev).node()
   864             tgt = scmutil.revsingle(repo, rev).node()
   858         else:
   865         checkconflict(repo, mark, force, tgt)
   859             marks[mark] = cur
   866         marks[mark] = tgt
   860         if not inactive and cur == marks[mark]:
   867         if not inactive and cur == marks[mark]:
   861             bookmarks.setcurrent(repo, mark)
   868             bookmarks.setcurrent(repo, mark)
   862         marks.write()
   869         marks.write()
   863 
   870 
   864     # Same message whether trying to deactivate the current bookmark (-i
   871     # Same message whether trying to deactivate the current bookmark (-i