Patchwork [4,of,4] bookmarks: make setcurrent with None an error

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 16, 2013, 3:18 a.m.
Message ID <2325d676e14d9c0383fd.1384571894@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/2973/
State Accepted
Commit 0f01d0692bc54551bc62c64f3dfd793708bd901b
Headers show

Comments

Siddharth Agarwal - Nov. 16, 2013, 3:18 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1384569700 28800
#      Fri Nov 15 18:41:40 2013 -0800
# Node ID 2325d676e14d9c0383fdc888e73cf869473f6132
# Parent  da43a40374316cb92dc3d50aeb2eff02ba3325ad
bookmarks: make setcurrent with None an error
David Soria Parra - Nov. 21, 2013, 11:12 p.m.
On 11/15/13, 7:18 PM, "Siddharth Agarwal" <sid0@fb.com> wrote:

># HG changeset patch
># User Siddharth Agarwal <sid0@fb.com>
># Date 1384569700 28800
>#      Fri Nov 15 18:41:40 2013 -0800
># Node ID 2325d676e14d9c0383fdc888e73cf869473f6132
># Parent  da43a40374316cb92dc3d50aeb2eff02ba3325ad
>bookmarks: make setcurrent with None an error

This series looks good for Œdefault¹.

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -106,13 +106,13 @@ 
     Set the name of the bookmark that we are on (hg update <bookmark>).
     The name is recorded in .hg/bookmarks.current
     '''
+    if mark not in repo._bookmarks:
+        raise AssertionError('bookmark %s does not exist!' % mark)
+
     current = repo._bookmarkcurrent
     if current == mark:
         return
 
-    if mark not in repo._bookmarks:
-        mark = ''
-
     wlock = repo.wlock()
     try:
         file = repo.opener('bookmarks.current', 'w', atomictemp=True)