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

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 16, 2013, 3:18 a.m.
Message ID <8392350894bd06146590.1384571891@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/2972/
State Accepted
Commit 85d9200ba9f0e73549ecbb57da5ad1271ed11f86
Headers show

Comments

Siddharth Agarwal - Nov. 16, 2013, 3:18 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@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.

Patch

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()):