bookmarks: discard current bookmark if absent from the bookmarks (issue2692) stable
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Sun, 13 Mar 2011 14:36:47 +0100
branchstable
changeset 13627 71a96f6c205d
parent 13626 4e96a5bee10d
child 13630 c8df759ee5ed
child 13631 29c800ee54cf
bookmarks: discard current bookmark if absent from the bookmarks (issue2692) After a rollback, the current bookmark might be absent from the bookmarks file. In that case we discard it instead of displaying a traceback during commit.
mercurial/bookmarks.py
tests/test-bookmarks-strip.t
--- a/mercurial/bookmarks.py	Sun Mar 13 16:13:25 2011 +0100
+++ b/mercurial/bookmarks.py	Sun Mar 13 14:36:47 2011 +0100
@@ -45,7 +45,7 @@
         file = repo.opener('bookmarks.current')
         # No readline() in posixfile_nt, reading everything is cheap
         mark = encoding.tolocal((file.readlines() or [''])[0])
-        if mark == '':
+        if mark == '' or mark not in repo._bookmarks:
             mark = None
         file.close()
     return mark
--- a/tests/test-bookmarks-strip.t	Sun Mar 13 16:13:25 2011 +0100
+++ b/tests/test-bookmarks-strip.t	Sun Mar 13 14:36:47 2011 +0100
@@ -84,19 +84,33 @@
   $ hg bookmarks
   no bookmarks set
 
+can we commit? (issue2692)
+
+  $ echo c > c
+  $ hg ci -Am rockon
+  adding c
+
 can you be added again?
 
   $ hg bookmarks markb
   $ hg bookmarks
-   * markb                     0:07f494440405
+   * markb                     1:fdb34407462c
 
 rollback dry run with rollback information
 
   $ hg rollback -n
+  repository tip rolled back to revision 0 (undo commit)
+  $ hg bookmarks
+   * markb                     1:fdb34407462c
+
+rollback dry run with rollback information and no commit undo
+
+  $ rm .hg/store/undo
+  $ hg rollback -n
   no rollback information available
   [1]
   $ hg bookmarks
-   * markb                     0:07f494440405
+   * markb                     1:fdb34407462c
 
   $ cd ..