commands.bookmark: use unsetcurrent instead of setcurrent with None
authorSiddharth Agarwal <sid0@fb.com>
Fri, 15 Nov 2013 18:06:01 -0800
changeset 20097 85d9200ba9f0
parent 20095 1c46b18b0e1c
child 20098 2880b45636ca
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.
mercurial/commands.py
--- a/mercurial/commands.py	Fri Nov 22 17:26:58 2013 -0600
+++ b/mercurial/commands.py	Fri Nov 15 18:06:01 2013 -0800
@@ -865,7 +865,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()
 
@@ -891,7 +891,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:
@@ -901,7 +901,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
@@ -913,7 +913,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()):