comparison mercurial/commands.py @ 22774:b17fd992d606

bookmarks: iterate bookmarks list even if it is known to be empty This clarifies that "no bookmarks set" is displayed in addition to the list of bookmarks. In JSON output, for example, [] should be written if empty, and "no bookmarks set" message should be skipped.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 03 Oct 2014 00:15:39 +0900
parents d4869b280cd6
children b59c2c8c45df
comparison
equal deleted inserted replaced
22773:90200e864ffc 22774:b17fd992d606
993 else: # show bookmarks 993 else: # show bookmarks
994 hexfn = ui.debugflag and hex or short 994 hexfn = ui.debugflag and hex or short
995 marks = repo._bookmarks 995 marks = repo._bookmarks
996 if len(marks) == 0: 996 if len(marks) == 0:
997 ui.status(_("no bookmarks set\n")) 997 ui.status(_("no bookmarks set\n"))
998 else: 998 for bmark, n in sorted(marks.iteritems()):
999 for bmark, n in sorted(marks.iteritems()): 999 current = repo._bookmarkcurrent
1000 current = repo._bookmarkcurrent 1000 if bmark == current:
1001 if bmark == current: 1001 prefix, label = '*', 'bookmarks.current'
1002 prefix, label = '*', 'bookmarks.current' 1002 else:
1003 else: 1003 prefix, label = ' ', ''
1004 prefix, label = ' ', '' 1004
1005 1005 if ui.quiet:
1006 if ui.quiet: 1006 ui.write("%s\n" % bmark, label=label)
1007 ui.write("%s\n" % bmark, label=label) 1007 else:
1008 else: 1008 pad = " " * (25 - encoding.colwidth(bmark))
1009 pad = " " * (25 - encoding.colwidth(bmark)) 1009 ui.write(" %s %s%s %d:%s\n" % (
1010 ui.write(" %s %s%s %d:%s\n" % ( 1010 prefix, bmark, pad, repo.changelog.rev(n), hexfn(n)),
1011 prefix, bmark, pad, repo.changelog.rev(n), hexfn(n)), 1011 label=label)
1012 label=label)
1013 1012
1014 @command('branch', 1013 @command('branch',
1015 [('f', 'force', None, 1014 [('f', 'force', None,
1016 _('set branch name even if it shadows an existing branch')), 1015 _('set branch name even if it shadows an existing branch')),
1017 ('C', 'clean', None, _('reset branch name to parent branch name'))], 1016 ('C', 'clean', None, _('reset branch name to parent branch name'))],