[PATCH 1 of 4] commands.bookmarks: separate out 'no bookmarks set' status messages

Siddharth Agarwal sid0 at fb.com
Tue Nov 19 14:45:42 CST 2013


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1384890450 28800
#      Tue Nov 19 11:47:30 2013 -0800
# Node ID 87229e6e9924304a060d573bade13faf77e9080e
# Parent  bf7df0d08d6e4026be624663c9b7f4c5e01acfed
commands.bookmarks: separate out 'no bookmarks set' status messages

Upcoming patches will acquire the wlock for write operations, such as make
inactive, but not read-only ones, such as list bookmarks. Separate out the
status messages so that the code paths can be separated.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -904,31 +904,31 @@
             bookmarks.setcurrent(repo, None)
         marks.write()
 
-    # 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:
+        if len(marks) == 0:
+            ui.status(_("no bookmarks set\n"))
+        elif not repo._bookmarkcurrent:
             ui.status(_("no active bookmark\n"))
         else:
             bookmarks.setcurrent(repo, None)
 
     else: # show bookmarks
-        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:
-                ui.write(" %s %-25s %d:%s\n" % (
-                    prefix, bmark, repo.changelog.rev(n), hexfn(n)),
-                    label=label)
+        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:
+                    ui.write(" %s %-25s %d:%s\n" % (
+                        prefix, bmark, repo.changelog.rev(n), hexfn(n)),
+                        label=label)
 
 @command('branch',
     [('f', 'force', None,


More information about the Mercurial-devel mailing list