[PATCH 2 of 2] bookmarks: make bookmarks.write deprecated

Laurent Charignon lcharignon at fb.com
Mon Nov 30 18:52:58 CST 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1448930318 28800
#      Mon Nov 30 16:38:38 2015 -0800
# Node ID 4c08a53f244a78832ad01a59fe495a2ba0c352e8
# Parent  dd44f8f830cab6059f5cc82e4d4b496bac8dce38
bookmarks: make bookmarks.write deprecated

This patches introduces a new devel warning for calls to bookmarks.write as we
want people to use bookmarks.recordchange instead. It also marks bookmarks.write
as deprecated.

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -81,7 +81,7 @@ class bmstore(dict):
         tr.hookargs['bookmark_moved'] = '1'
 
     def write(self):
-        '''Write bookmarks
+        '''Deprecated, Write bookmarks, use recordchange instead
 
         Write the given bookmark => hash dictionary to the .hg/bookmarks file
         in a format equal to those of localtags.
@@ -90,11 +90,9 @@ class bmstore(dict):
         can be copied back on rollback.
         '''
         repo = self._repo
-        if (repo.ui.configbool('devel', 'all-warnings')
-                or repo.ui.configbool('devel', 'check-locks')):
-            l = repo._wlockref and repo._wlockref()
-            if l is None or not l.held:
-                repo.ui.develwarn('bookmarks write with no wlock')
+        if repo.ui.configbool('devel', 'all-warnings'):
+            repo.ui.develwarn('bookmarks.write is deprecated,'
+                              ' please use bookmarks.recordchange')
 
         tr = repo.currenttransaction()
         if tr:
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -557,6 +557,7 @@ be exchanged)
   $ hg -R repo1 bookmarks -f -r 3 DIFF_ADV_ON_REPO1
   $ hg -R repo1 bookmarks -f -r 3 DIFF_DIVERGED
   $ hg -R repo1 -q --config extensions.mq= strip 4
+  devel-warn: bookmarks.write is deprecated, please use bookmarks.recordchange at: /Users/lcharignon/repos/hg/mercurial/repair.py:217 (strip)
   $ hg -R repo1 log -G --template '{node|short} ({bookmarks})'
   o  6100d3090acf (DIFF_ADV_ON_REPO1 DIFF_DIVERGED)
   |
@@ -574,6 +575,7 @@ be exchanged)
   $ hg -R repo2 bookmarks -f -r 4 DIFF_ADV_ON_REPO2
   $ hg -R repo2 bookmarks -f -r 4 DIFF_DIVERGED
   $ hg -R repo2 -q --config extensions.mq= strip 3
+  devel-warn: bookmarks.write is deprecated, please use bookmarks.recordchange at: /Users/lcharignon/repos/hg/mercurial/repair.py:217 (strip)
   $ hg -R repo2 log -G --template '{node|short} ({bookmarks})'
   o  e7bd5218ca15 (DIFF_ADV_ON_REPO2 DIFF_DIVERGED)
   |
diff --git a/tests/test-bookmarks-rebase.t b/tests/test-bookmarks-rebase.t
--- a/tests/test-bookmarks-rebase.t
+++ b/tests/test-bookmarks-rebase.t
@@ -39,6 +39,7 @@ rebase
   $ hg rebase -s two -d one
   rebasing 3:2ae46b1d99a7 "3" (tip two)
   saved backup bundle to $TESTTMP/.hg/strip-backup/2ae46b1d99a7-e6b057bc-backup.hg (glob)
+  devel-warn: bookmarks.write is deprecated, please use bookmarks.recordchange at: /Users/lcharignon/repos/hg/mercurial/repair.py:217 (strip)
 
   $ hg log
   changeset:   3:42e5ed2cdcf4
diff --git a/tests/test-bookmarks-strip.t b/tests/test-bookmarks-strip.t
--- a/tests/test-bookmarks-strip.t
+++ b/tests/test-bookmarks-strip.t
@@ -57,6 +57,7 @@ strip to revision 1
 
   $ hg strip 1
   saved backup bundle to $TESTTMP/.hg/strip-backup/*-backup.hg (glob)
+  devel-warn: bookmarks.write is deprecated, please use bookmarks.recordchange at: /Users/lcharignon/repos/hg/mercurial/repair.py:217 (strip)
 
 list bookmarks
 
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -678,6 +678,7 @@ test stripping a non-checked-out but boo
   $ hg book four
   $ hg --config extensions.mq= strip 3
   saved backup bundle to * (glob)
+  devel-warn: bookmarks.write is deprecated, please use bookmarks.recordchange at: /Users/lcharignon/repos/hg/mercurial/repair.py:217 (strip)
 should-end-on-two should end up pointing to revision 2, as that's the
 tipmost surviving ancestor of the stripped revision.
   $ hg log --graph


More information about the Mercurial-devel mailing list