mercurial/commands.py
changeset 24947 a02d293a1079
parent 24945 e0b0fbd47491
child 24994 713b09fc9fbb
equal deleted inserted replaced
24946:c44534209a0a 24947:a02d293a1079
   977             if delete:
   977             if delete:
   978                 for mark in names:
   978                 for mark in names:
   979                     if mark not in marks:
   979                     if mark not in marks:
   980                         raise util.Abort(_("bookmark '%s' does not exist") %
   980                         raise util.Abort(_("bookmark '%s' does not exist") %
   981                                          mark)
   981                                          mark)
   982                     if mark == repo._bookmarkcurrent:
   982                     if mark == repo._activebookmark:
   983                         bookmarks.deactivate(repo)
   983                         bookmarks.deactivate(repo)
   984                     del marks[mark]
   984                     del marks[mark]
   985                 marks.write()
   985                 marks.write()
   986 
   986 
   987             elif rename:
   987             elif rename:
   992                 mark = checkformat(names[0])
   992                 mark = checkformat(names[0])
   993                 if rename not in marks:
   993                 if rename not in marks:
   994                     raise util.Abort(_("bookmark '%s' does not exist") % rename)
   994                     raise util.Abort(_("bookmark '%s' does not exist") % rename)
   995                 checkconflict(repo, mark, cur, force)
   995                 checkconflict(repo, mark, cur, force)
   996                 marks[mark] = marks[rename]
   996                 marks[mark] = marks[rename]
   997                 if repo._bookmarkcurrent == rename and not inactive:
   997                 if repo._activebookmark == rename and not inactive:
   998                     bookmarks.activate(repo, mark)
   998                     bookmarks.activate(repo, mark)
   999                 del marks[rename]
   999                 del marks[rename]
  1000                 marks.write()
  1000                 marks.write()
  1001 
  1001 
  1002             elif names:
  1002             elif names:
  1003                 newact = None
  1003                 newact = None
  1004                 for mark in names:
  1004                 for mark in names:
  1005                     mark = checkformat(mark)
  1005                     mark = checkformat(mark)
  1006                     if newact is None:
  1006                     if newact is None:
  1007                         newact = mark
  1007                         newact = mark
  1008                     if inactive and mark == repo._bookmarkcurrent:
  1008                     if inactive and mark == repo._activebookmark:
  1009                         bookmarks.deactivate(repo)
  1009                         bookmarks.deactivate(repo)
  1010                         return
  1010                         return
  1011                     tgt = cur
  1011                     tgt = cur
  1012                     if rev:
  1012                     if rev:
  1013                         tgt = scmutil.revsingle(repo, rev).node()
  1013                         tgt = scmutil.revsingle(repo, rev).node()
  1014                     checkconflict(repo, mark, cur, force, tgt)
  1014                     checkconflict(repo, mark, cur, force, tgt)
  1015                     marks[mark] = tgt
  1015                     marks[mark] = tgt
  1016                 if not inactive and cur == marks[newact] and not rev:
  1016                 if not inactive and cur == marks[newact] and not rev:
  1017                     bookmarks.activate(repo, newact)
  1017                     bookmarks.activate(repo, newact)
  1018                 elif cur != tgt and newact == repo._bookmarkcurrent:
  1018                 elif cur != tgt and newact == repo._activebookmark:
  1019                     bookmarks.deactivate(repo)
  1019                     bookmarks.deactivate(repo)
  1020                 marks.write()
  1020                 marks.write()
  1021 
  1021 
  1022             elif inactive:
  1022             elif inactive:
  1023                 if len(marks) == 0:
  1023                 if len(marks) == 0:
  1024                     ui.status(_("no bookmarks set\n"))
  1024                     ui.status(_("no bookmarks set\n"))
  1025                 elif not repo._bookmarkcurrent:
  1025                 elif not repo._activebookmark:
  1026                     ui.status(_("no active bookmark\n"))
  1026                     ui.status(_("no active bookmark\n"))
  1027                 else:
  1027                 else:
  1028                     bookmarks.deactivate(repo)
  1028                     bookmarks.deactivate(repo)
  1029         finally:
  1029         finally:
  1030             wlock.release()
  1030             wlock.release()
  1033         hexfn = fm.hexfunc
  1033         hexfn = fm.hexfunc
  1034         marks = repo._bookmarks
  1034         marks = repo._bookmarks
  1035         if len(marks) == 0 and not fm:
  1035         if len(marks) == 0 and not fm:
  1036             ui.status(_("no bookmarks set\n"))
  1036             ui.status(_("no bookmarks set\n"))
  1037         for bmark, n in sorted(marks.iteritems()):
  1037         for bmark, n in sorted(marks.iteritems()):
  1038             current = repo._bookmarkcurrent
  1038             current = repo._activebookmark
  1039             if bmark == current:
  1039             if bmark == current:
  1040                 prefix, label = '*', 'bookmarks.current'
  1040                 prefix, label = '*', 'bookmarks.current'
  1041             else:
  1041             else:
  1042                 prefix, label = ' ', ''
  1042                 prefix, label = ' ', ''
  1043 
  1043 
  1504                                opts.get('user') or old.user(),
  1504                                opts.get('user') or old.user(),
  1505                                opts.get('date') or old.date(),
  1505                                opts.get('date') or old.date(),
  1506                                match,
  1506                                match,
  1507                                extra=extra)
  1507                                extra=extra)
  1508 
  1508 
  1509         current = repo._bookmarkcurrent
  1509         current = repo._activebookmark
  1510         marks = old.bookmarks()
  1510         marks = old.bookmarks()
  1511         node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
  1511         node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
  1512         if node == old.node():
  1512         if node == old.node():
  1513             ui.status(_("nothing changed\n"))
  1513             ui.status(_("nothing changed\n"))
  1514             return 1
  1514             return 1
  4700         node = opts.get('rev')
  4700         node = opts.get('rev')
  4701 
  4701 
  4702     if node:
  4702     if node:
  4703         node = scmutil.revsingle(repo, node).node()
  4703         node = scmutil.revsingle(repo, node).node()
  4704 
  4704 
  4705     if not node and repo._bookmarkcurrent:
  4705     if not node and repo._activebookmark:
  4706         bmheads = repo.bookmarkheads(repo._bookmarkcurrent)
  4706         bmheads = repo.bookmarkheads(repo._activebookmark)
  4707         curhead = repo[repo._bookmarkcurrent].node()
  4707         curhead = repo[repo._activebookmark].node()
  4708         if len(bmheads) == 2:
  4708         if len(bmheads) == 2:
  4709             if curhead == bmheads[0]:
  4709             if curhead == bmheads[0]:
  4710                 node = bmheads[1]
  4710                 node = bmheads[1]
  4711             else:
  4711             else:
  4712                 node = bmheads[0]
  4712                 node = bmheads[0]
  4717         elif len(bmheads) <= 1:
  4717         elif len(bmheads) <= 1:
  4718             raise util.Abort(_("no matching bookmark to merge - "
  4718             raise util.Abort(_("no matching bookmark to merge - "
  4719                 "please merge with an explicit rev or bookmark"),
  4719                 "please merge with an explicit rev or bookmark"),
  4720                 hint=_("run 'hg heads' to see all heads"))
  4720                 hint=_("run 'hg heads' to see all heads"))
  4721 
  4721 
  4722     if not node and not repo._bookmarkcurrent:
  4722     if not node and not repo._activebookmark:
  4723         branch = repo[None].branch()
  4723         branch = repo[None].branch()
  4724         bheads = repo.branchheads(branch)
  4724         bheads = repo.branchheads(branch)
  4725         nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
  4725         nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
  4726 
  4726 
  4727         if len(nbhs) > 2:
  4727         if len(nbhs) > 2:
  5047             if inst.hint:
  5047             if inst.hint:
  5048                 ui.warn(_("(%s)\n") % inst.hint)
  5048                 ui.warn(_("(%s)\n") % inst.hint)
  5049             return 0
  5049             return 0
  5050         if not ret and not checkout:
  5050         if not ret and not checkout:
  5051             if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
  5051             if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
  5052                 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
  5052                 ui.status(_("updating bookmark %s\n") % repo._activebookmark)
  5053         return ret
  5053         return ret
  5054     if modheads > 1:
  5054     if modheads > 1:
  5055         currentbranchheads = len(repo.branchheads())
  5055         currentbranchheads = len(repo.branchheads())
  5056         if currentbranchheads == modheads:
  5056         if currentbranchheads == modheads:
  5057             ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
  5057             ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
  5912         ui.write(m, label='log.branch')
  5912         ui.write(m, label='log.branch')
  5913     else:
  5913     else:
  5914         ui.status(m, label='log.branch')
  5914         ui.status(m, label='log.branch')
  5915 
  5915 
  5916     if marks:
  5916     if marks:
  5917         current = repo._bookmarkcurrent
  5917         current = repo._activebookmark
  5918         # i18n: column positioning for "hg summary"
  5918         # i18n: column positioning for "hg summary"
  5919         ui.write(_('bookmarks:'), label='log.bookmark')
  5919         ui.write(_('bookmarks:'), label='log.bookmark')
  5920         if current is not None:
  5920         if current is not None:
  5921             if current in marks:
  5921             if current in marks:
  5922                 ui.write(' *' + current, label='bookmarks.current')
  5922                 ui.write(' *' + current, label='bookmarks.current')
  6403     else:
  6403     else:
  6404         ret = hg.update(repo, rev)
  6404         ret = hg.update(repo, rev)
  6405 
  6405 
  6406     if not ret and movemarkfrom:
  6406     if not ret and movemarkfrom:
  6407         if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
  6407         if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
  6408             ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
  6408             ui.status(_("updating bookmark %s\n") % repo._activebookmark)
  6409     elif brev in repo._bookmarks:
  6409     elif brev in repo._bookmarks:
  6410         bookmarks.activate(repo, brev)
  6410         bookmarks.activate(repo, brev)
  6411         ui.status(_("(activating bookmark %s)\n") % brev)
  6411         ui.status(_("(activating bookmark %s)\n") % brev)
  6412     elif brev:
  6412     elif brev:
  6413         if repo._bookmarkcurrent:
  6413         if repo._activebookmark:
  6414             ui.status(_("(leaving bookmark %s)\n") %
  6414             ui.status(_("(leaving bookmark %s)\n") %
  6415                       repo._bookmarkcurrent)
  6415                       repo._activebookmark)
  6416         bookmarks.deactivate(repo)
  6416         bookmarks.deactivate(repo)
  6417 
  6417 
  6418     return ret
  6418     return ret
  6419 
  6419 
  6420 @command('verify', [])
  6420 @command('verify', [])