--- a/hgext/show.py Fri Apr 07 10:26:13 2017 -0700
+++ b/hgext/show.py Fri Apr 07 10:46:32 2017 -0700
@@ -19,6 +19,7 @@
cmdutil,
commands,
error,
+ formatter,
pycompat,
registrar,
)
@@ -109,8 +110,11 @@
"""bookmarks and their associated changeset"""
marks = repo._bookmarks
if not len(marks):
- # TODO json output is corrupted; consider using formatter
- ui.write(_('(no bookmarks set)\n'))
+ # This is a bit hacky. Ideally, templates would have a way to
+ # specify an empty output, but we shouldn't corrupt JSON while
+ # waiting for this functionality.
+ if not isinstance(fm, formatter.jsonformatter):
+ ui.write(_('(no bookmarks set)\n'))
return
active = repo._activebookmark
--- a/tests/test-show.t Fri Apr 07 10:26:13 2017 -0700
+++ b/tests/test-show.t Fri Apr 07 10:46:32 2017 -0700
@@ -114,4 +114,12 @@
}
]
+JSON works with no bookmarks
+
+ $ hg book -d a-longer-bookmark
+ $ hg book -d book1
+ $ hg show bookmarks -T json
+ [
+ ]
+
$ cd ..