comparison mercurial/commands.py @ 17822:c284085d17a8

bookmarks: further flatten code This hopefully clarifies the behavior when no NAME is passed, by separating the branches for listing bookmarks vs. deactivating the current bookmark.
author Kevin Bullock <kbullock@ringworld.org>
date Thu, 18 Oct 2012 16:34:13 -0500
parents 361ab1e2086f
children 1cb51d65453d
comparison
equal deleted inserted replaced
17821:361ab1e2086f 17822:c284085d17a8
848 marks[mark] = cur 848 marks[mark] = cur
849 if not inactive and cur == marks[mark]: 849 if not inactive and cur == marks[mark]:
850 bookmarks.setcurrent(repo, mark) 850 bookmarks.setcurrent(repo, mark)
851 bookmarks.write(repo) 851 bookmarks.write(repo)
852 852
853 # Same message whether trying to deactivate the current bookmark (-i
854 # with no NAME) or listing bookmarks
855 elif len(marks) == 0:
856 ui.status(_("no bookmarks set\n"))
857
858 elif inactive:
859 if not repo._bookmarkcurrent:
860 ui.status(_("no active bookmark\n"))
861 else:
862 bookmarks.setcurrent(repo, None)
863
853 else: # show bookmarks 864 else: # show bookmarks
854 if len(marks) == 0: 865 for bmark, n in sorted(marks.iteritems()):
855 ui.status(_("no bookmarks set\n")) 866 current = repo._bookmarkcurrent
856 elif inactive: 867 if bmark == current and n == cur:
857 if not repo._bookmarkcurrent: 868 prefix, label = '*', 'bookmarks.current'
858 ui.status(_("no active bookmark\n"))
859 else: 869 else:
860 bookmarks.setcurrent(repo, None) 870 prefix, label = ' ', ''
861 else: 871
862 for bmark, n in sorted(marks.iteritems()): 872 if ui.quiet:
863 current = repo._bookmarkcurrent 873 ui.write("%s\n" % bmark, label=label)
864 if bmark == current and n == cur: 874 else:
865 prefix, label = '*', 'bookmarks.current' 875 ui.write(" %s %-25s %d:%s\n" % (
866 else: 876 prefix, bmark, repo.changelog.rev(n), hexfn(n)),
867 prefix, label = ' ', '' 877 label=label)
868
869 if ui.quiet:
870 ui.write("%s\n" % bmark, label=label)
871 else:
872 ui.write(" %s %-25s %d:%s\n" % (
873 prefix, bmark, repo.changelog.rev(n), hexfn(n)),
874 label=label)
875 878
876 @command('branch', 879 @command('branch',
877 [('f', 'force', None, 880 [('f', 'force', None,
878 _('set branch name even if it shadows an existing branch')), 881 _('set branch name even if it shadows an existing branch')),
879 ('C', 'clean', None, _('reset branch name to parent branch name'))], 882 ('C', 'clean', None, _('reset branch name to parent branch name'))],