Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 33026:f5f4c72de71a
bookmarks: factor out bookmark printing from commands
author | Sean Farley <sean@farley.io> |
---|---|
date | Tue, 20 Jun 2017 16:36:25 -0700 |
parents | 4b81776baa7a |
children | f66be4caeaab |
comparison
equal
deleted
inserted
replaced
33025:4b81776baa7a | 33026:f5f4c72de71a |
---|---|
978 elif not repo._activebookmark: | 978 elif not repo._activebookmark: |
979 ui.status(_("no active bookmark\n")) | 979 ui.status(_("no active bookmark\n")) |
980 else: | 980 else: |
981 bookmarks.deactivate(repo) | 981 bookmarks.deactivate(repo) |
982 else: # show bookmarks | 982 else: # show bookmarks |
983 fm = ui.formatter('bookmarks', opts) | 983 bookmarks.printbookmarks(ui, repo, **opts) |
984 hexfn = fm.hexfunc | |
985 marks = repo._bookmarks | |
986 if len(marks) == 0 and fm.isplain(): | |
987 ui.status(_("no bookmarks set\n")) | |
988 for bmark, n in sorted(marks.iteritems()): | |
989 active = repo._activebookmark | |
990 if bmark == active: | |
991 prefix, label = '*', bookmarks.activebookmarklabel | |
992 else: | |
993 prefix, label = ' ', '' | |
994 | |
995 fm.startitem() | |
996 if not ui.quiet: | |
997 fm.plain(' %s ' % prefix, label=label) | |
998 fm.write('bookmark', '%s', bmark, label=label) | |
999 pad = " " * (25 - encoding.colwidth(bmark)) | |
1000 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s', | |
1001 repo.changelog.rev(n), hexfn(n), label=label) | |
1002 fm.data(active=(bmark == active)) | |
1003 fm.plain('\n') | |
1004 fm.end() | |
1005 | 984 |
1006 @command('branch', | 985 @command('branch', |
1007 [('f', 'force', None, | 986 [('f', 'force', None, |
1008 _('set branch name even if it shadows an existing branch')), | 987 _('set branch name even if it shadows an existing branch')), |
1009 ('C', 'clean', None, _('reset branch name to parent branch name'))], | 988 ('C', 'clean', None, _('reset branch name to parent branch name'))], |