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

login
register
mail settings
Submitter Siddharth Agarwal
Date Dec. 20, 2013, 4:04 p.m.
Message ID <cc4fbea8fd8863d0e928.1387555441@sid0x220>
Download mbox | patch
Permalink /patch/3219/
State Accepted
Commit 1053f5a7bbc617ce91cc4b577a2dfc5f3658b731
Headers show

Comments

Siddharth Agarwal - Dec. 20, 2013, 4:04 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1384890450 28800
#      Tue Nov 19 11:47:30 2013 -0800
# Node ID cc4fbea8fd8863d0e92868fccd9217c3152ae3e5
# Parent  77393672ef93c70213cf61be650a23883ec94045
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.
Siddharth Agarwal - Dec. 20, 2013, 4:10 p.m.
On 12/20/2013 09:34 PM, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1384890450 28800
> #      Tue Nov 19 11:47:30 2013 -0800
> # Node ID cc4fbea8fd8863d0e92868fccd9217c3152ae3e5
> # Parent  77393672ef93c70213cf61be650a23883ec94045
> commands.bookmarks: separate out 'no bookmarks set' status messages

(Sorry for not sending this in a timely manner -- I was on vacation for 
the last three weeks.)

Patch

diff -r 77393672ef93c70213cf61be650a23883ec94045 -r cc4fbea8fd8863d0e92868fccd9217c3152ae3e5 mercurial/commands.py
--- a/mercurial/commands.py	Sun Nov 17 16:32:23 2013 -0800
+++ b/mercurial/commands.py	Tue Nov 19 11:47:30 2013 -0800
@@ -906,31 +906,31 @@  def bookmark(ui, repo, *names, **opts):
             bookmarks.unsetcurrent(repo)
         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.unsetcurrent(repo)
 
     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,