changeset 22774:b17fd992d606

bookmarks: iterate bookmarks list even if it is known to be empty This clarifies that "no bookmarks set" is displayed in addition to the list of bookmarks. In JSON output, for example, [] should be written if empty, and "no bookmarks set" message should be skipped.
author Yuya Nishihara <yuya@tcha.org>
date Fri, 03 Oct 2014 00:15:39 +0900
parents 90200e864ffc
children b59c2c8c45df
files mercurial/commands.py
diffstat 1 files changed, 14 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Mon Oct 06 07:29:40 2014 -0700
+++ b/mercurial/commands.py	Fri Oct 03 00:15:39 2014 +0900
@@ -995,21 +995,20 @@
         marks = repo._bookmarks
         if len(marks) == 0:
             ui.status(_("no bookmarks set\n"))
-        else:
-            for bmark, n in sorted(marks.iteritems()):
-                current = repo._bookmarkcurrent
-                if bmark == current:
-                    prefix, label = '*', 'bookmarks.current'
-                else:
-                    prefix, label = ' ', ''
-
-                if ui.quiet:
-                    ui.write("%s\n" % bmark, label=label)
-                else:
-                    pad = " " * (25 - encoding.colwidth(bmark))
-                    ui.write(" %s %s%s %d:%s\n" % (
-                        prefix, bmark, pad, repo.changelog.rev(n), hexfn(n)),
-                        label=label)
+        for bmark, n in sorted(marks.iteritems()):
+            current = repo._bookmarkcurrent
+            if bmark == current:
+                prefix, label = '*', 'bookmarks.current'
+            else:
+                prefix, label = ' ', ''
+
+            if ui.quiet:
+                ui.write("%s\n" % bmark, label=label)
+            else:
+                pad = " " * (25 - encoding.colwidth(bmark))
+                ui.write(" %s %s%s %d:%s\n" % (
+                    prefix, bmark, pad, repo.changelog.rev(n), hexfn(n)),
+                    label=label)
 
 @command('branch',
     [('f', 'force', None,