[PATCH 1 of 4] commands.bookmark: use unsetcurrent instead of setcurrent with None

Siddharth Agarwal sid0 at fb.com
Sat Nov 16 03:18:11 UTC 2013


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1384567561 28800
#      Fri Nov 15 18:06:01 2013 -0800
# Node ID 8392350894bd06146590e7db0f9cc87c249587ef
# Parent  c38c3fdc8b9317ba09e03ab09364c3800da7c50c
commands.bookmark: use unsetcurrent instead of setcurrent with None

There are currently two different ways we can have no active bookmark:
.hg/bookmarks.current being missing and it being an empty file. This patch and
upcoming ones make an empty file the only way to represent no active bookmarks.
This is the right choice because it matches the state that a new repository
without bookmarks will be in.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -863,7 +863,7 @@
             if mark not in marks:
                 raise util.Abort(_("bookmark '%s' does not exist") % mark)
             if mark == repo._bookmarkcurrent:
-                bookmarks.setcurrent(repo, None)
+                bookmarks.unsetcurrent(repo)
             del marks[mark]
         marks.write()
 
@@ -889,7 +889,7 @@
             if newact is None:
                 newact = mark
             if inactive and mark == repo._bookmarkcurrent:
-                bookmarks.setcurrent(repo, None)
+                bookmarks.unsetcurrent(repo)
                 return
             tgt = cur
             if rev:
@@ -899,7 +899,7 @@
         if not inactive and cur == marks[newact] and not rev:
             bookmarks.setcurrent(repo, newact)
         elif cur != tgt and newact == repo._bookmarkcurrent:
-            bookmarks.setcurrent(repo, None)
+            bookmarks.unsetcurrent(repo)
         marks.write()
 
     # Same message whether trying to deactivate the current bookmark (-i
@@ -911,7 +911,7 @@
         if not repo._bookmarkcurrent:
             ui.status(_("no active bookmark\n"))
         else:
-            bookmarks.setcurrent(repo, None)
+            bookmarks.unsetcurrent(repo)
 
     else: # show bookmarks
         for bmark, n in sorted(marks.iteritems()):


More information about the Mercurial-devel mailing list