Patchwork [1,of,5] commands.bookmarks: separate out 'no bookmarks set' status messages

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 22, 2013, 1:13 a.m.
Message ID <2472f2dcf8fb9b691c03.1385082789@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/3087/
State Superseded
Commit 1053f5a7bbc617ce91cc4b577a2dfc5f3658b731
Headers show

Comments

Siddharth Agarwal - Nov. 22, 2013, 1:13 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1384890450 28800
#      Tue Nov 19 11:47:30 2013 -0800
# Node ID 2472f2dcf8fb9b691c03bb9e404b55da90b8d672
# Parent  37133bd1102d0fc85fe762b0b779b498d1031324
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.

Patch

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,