hgext/show.py
changeset 31859 8e282aa3c3ff
parent 31858 ad366d57d574
child 31943 3e9f118cc834
equal deleted inserted replaced
31858:ad366d57d574 31859:8e282aa3c3ff
    17 from mercurial.i18n import _
    17 from mercurial.i18n import _
    18 from mercurial import (
    18 from mercurial import (
    19     cmdutil,
    19     cmdutil,
    20     commands,
    20     commands,
    21     error,
    21     error,
       
    22     formatter,
    22     pycompat,
    23     pycompat,
    23     registrar,
    24     registrar,
    24 )
    25 )
    25 
    26 
    26 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
    27 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
   107 @showview('bookmarks', fmtopic='bookmarks')
   108 @showview('bookmarks', fmtopic='bookmarks')
   108 def showbookmarks(ui, repo, fm):
   109 def showbookmarks(ui, repo, fm):
   109     """bookmarks and their associated changeset"""
   110     """bookmarks and their associated changeset"""
   110     marks = repo._bookmarks
   111     marks = repo._bookmarks
   111     if not len(marks):
   112     if not len(marks):
   112         # TODO json output is corrupted; consider using formatter
   113         # This is a bit hacky. Ideally, templates would have a way to
   113         ui.write(_('(no bookmarks set)\n'))
   114         # specify an empty output, but we shouldn't corrupt JSON while
       
   115         # waiting for this functionality.
       
   116         if not isinstance(fm, formatter.jsonformatter):
       
   117             ui.write(_('(no bookmarks set)\n'))
   114         return
   118         return
   115 
   119 
   116     active = repo._activebookmark
   120     active = repo._activebookmark
   117     longestname = max(len(b) for b in marks)
   121     longestname = max(len(b) for b in marks)
   118     # TODO consider exposing longest shortest(node).
   122     # TODO consider exposing longest shortest(node).