##// END OF EJS Templates
bookmarks: factor out bookmark printing from commands
Sean Farley -
r33010:f5f4c72d default
parent child Browse files
Show More
@@ -764,3 +764,31 b' def addbookmarks(repo, tr, names, rev=No'
764 elif cur != tgt and newact == repo._activebookmark:
764 elif cur != tgt and newact == repo._activebookmark:
765 deactivate(repo)
765 deactivate(repo)
766 marks.recordchange(tr)
766 marks.recordchange(tr)
767
768 def printbookmarks(ui, repo, **opts):
769 """print bookmarks to a formatter
770
771 Provides a way for extensions to control how bookmarks are printed.
772 """
773 fm = ui.formatter('bookmarks', opts)
774 hexfn = fm.hexfunc
775 marks = repo._bookmarks
776 if len(marks) == 0 and fm.isplain():
777 ui.status(_("no bookmarks set\n"))
778 for bmark, n in sorted(marks.iteritems()):
779 active = repo._activebookmark
780 if bmark == active:
781 prefix, label = '*', activebookmarklabel
782 else:
783 prefix, label = ' ', ''
784
785 fm.startitem()
786 if not ui.quiet:
787 fm.plain(' %s ' % prefix, label=label)
788 fm.write('bookmark', '%s', bmark, label=label)
789 pad = " " * (25 - encoding.colwidth(bmark))
790 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
791 repo.changelog.rev(n), hexfn(n), label=label)
792 fm.data(active=(bmark == active))
793 fm.plain('\n')
794 fm.end()
@@ -980,28 +980,7 b' def bookmark(ui, repo, *names, **opts):'
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,
General Comments 0
You need to be logged in to leave comments. Login now