changeset 17822:c284085d17a8

bookmarks: further flatten code This hopefully clarifies the behavior when no NAME is passed, by separating the branches for listing bookmarks vs. deactivating the current bookmark.
author Kevin Bullock <kbullock@ringworld.org>
date Thu, 18 Oct 2012 16:34:13 -0500
parents 361ab1e2086f
children 0fc1ce271ee6
files mercurial/commands.py
diffstat 1 files changed, 24 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Oct 17 21:42:06 2012 -0500
+++ b/mercurial/commands.py	Thu Oct 18 16:34:13 2012 -0500
@@ -850,28 +850,31 @@
             bookmarks.setcurrent(repo, mark)
         bookmarks.write(repo)
 
-    else: # show bookmarks
-        if len(marks) == 0:
-            ui.status(_("no bookmarks set\n"))
-        elif inactive:
-            if not repo._bookmarkcurrent:
-                ui.status(_("no active bookmark\n"))
-            else:
-                bookmarks.setcurrent(repo, None)
+    # Same message whether trying to deactivate the current bookmark (-i
+    # with no NAME) or listing bookmarks
+    elif len(marks) == 0:
+        ui.status(_("no bookmarks set\n"))
+
+    elif inactive:
+        if not repo._bookmarkcurrent:
+            ui.status(_("no active bookmark\n"))
         else:
-            for bmark, n in sorted(marks.iteritems()):
-                current = repo._bookmarkcurrent
-                if bmark == current and n == cur:
-                    prefix, label = '*', 'bookmarks.current'
-                else:
-                    prefix, label = ' ', ''
-
-                if ui.quiet:
-                    ui.write("%s\n" % bmark, label=label)
-                else:
-                    ui.write(" %s %-25s %d:%s\n" % (
-                        prefix, bmark, repo.changelog.rev(n), hexfn(n)),
-                        label=label)
+            bookmarks.setcurrent(repo, None)
+
+    else: # show bookmarks
+        for bmark, n in sorted(marks.iteritems()):
+            current = repo._bookmarkcurrent
+            if bmark == current and n == cur:
+                prefix, label = '*', 'bookmarks.current'
+            else:
+                prefix, label = ' ', ''
+
+            if ui.quiet:
+                ui.write("%s\n" % bmark, label=label)
+            else:
+                ui.write(" %s %-25s %d:%s\n" % (
+                    prefix, bmark, repo.changelog.rev(n), hexfn(n)),
+                    label=label)
 
 @command('branch',
     [('f', 'force', None,