##// END OF EJS Templates
bookmarks: factor method _printer out of for loop in printbookmarks...
Sean Farley -
r33011:8299eb9b default
parent child Browse files
Show More
@@ -765,16 +765,35 b' def addbookmarks(repo, tr, names, rev=No'
765 765 deactivate(repo)
766 766 marks.recordchange(tr)
767 767
768 def _printbookmarks(ui, repo, bmarks, **opts):
769 """private method to print bookmarks
770
771 Provides a way for extensions to control how bookmarks are printed (e.g.
772 prepend or postpend names)
773 """
774 fm = ui.formatter('bookmarks', opts)
775 hexfn = fm.hexfunc
776 if len(bmarks) == 0 and fm.isplain():
777 ui.status(_("no bookmarks set\n"))
778 for bmark, (n, prefix, label) in sorted(bmarks.iteritems()):
779 fm.startitem()
780 if not ui.quiet:
781 fm.plain(' %s ' % prefix, label=label)
782 fm.write('bookmark', '%s', bmark, label=label)
783 pad = " " * (25 - encoding.colwidth(bmark))
784 fm.condwrite(not ui.quiet, 'rev node', pad + ' %d:%s',
785 repo.changelog.rev(n), hexfn(n), label=label)
786 fm.data(active=(activebookmarklabel in label))
787 fm.plain('\n')
788 fm.end()
789
768 790 def printbookmarks(ui, repo, **opts):
769 791 """print bookmarks to a formatter
770 792
771 793 Provides a way for extensions to control how bookmarks are printed.
772 794 """
773 fm = ui.formatter('bookmarks', opts)
774 hexfn = fm.hexfunc
775 795 marks = repo._bookmarks
776 if len(marks) == 0 and fm.isplain():
777 ui.status(_("no bookmarks set\n"))
796 bmarks = {}
778 797 for bmark, n in sorted(marks.iteritems()):
779 798 active = repo._activebookmark
780 799 if bmark == active:
@@ -782,13 +801,5 b' def printbookmarks(ui, repo, **opts):'
782 801 else:
783 802 prefix, label = ' ', ''
784 803
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()
804 bmarks[bmark] = (n, prefix, label)
805 _printbookmarks(ui, repo, bmarks, **opts)
General Comments 0
You need to be logged in to leave comments. Login now