Rev 3958: Add some deprecation warnings. in lp:///~jameinel/bzr/win32-shelve
John Arbash Meinel
john at arbash-meinel.com
Fri Jan 23 18:26:21 GMT 2009
At lp:///~jameinel/bzr/win32-shelve
------------------------------------------------------------
revno: 3958
revision-id: john at arbash-meinel.com-20090123182613-iozkh04uv69lt3p4
parent: john at arbash-meinel.com-20090123175911-ymf5xvskhkk9yh5o
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: win32-shelve
timestamp: Fri 2009-01-23 12:26:13 -0600
message:
Add some deprecation warnings.
-------------- next part --------------
=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py 2009-01-23 17:59:11 +0000
+++ b/bzrlib/workingtree_4.py 2009-01-23 18:26:13 +0000
@@ -25,6 +25,7 @@
from cStringIO import StringIO
import os
import sys
+import weakref
from bzrlib.lazy_import import lazy_import
lazy_import(globals(), """
@@ -1018,15 +1019,27 @@
"""
return self.inventory
- @needs_read_lock
def revision_tree(self, revision_id):
"""See Tree.revision_tree.
WorkingTree4 supplies revision_trees for any basis tree.
"""
- # XXX: It would be better to call self._must_be_locked at this point,
- # rather than using @needs_read_lock for revision_tree()
- # self._must_be_locked()
+ try:
+ self._must_be_locked()
+ except errors.ObjectNotLocked:
+ symbol_versioning.warn('As of bzr 1.12 you should grab a'
+ ' lock on the working tree before calling'
+ ' wt.basis_tree() or wt.revision_tree()'
+ ' and only hold on to the returned tree'
+ ' for the lifetime of the lock.',
+ DeprecationWarning, stacklevel=2)
+ # We preserve the @needs_read_lock for self._revision_tree for
+ # compatibility, but we can't have it on this function, or we can't
+ # tell that the caller isn't holding a lock.
+ return self._revision_tree(revision_id)
+
+ @needs_read_lock
+ def _revision_tree(self, revision_id):
dirstate = self.current_dirstate()
parent_ids = dirstate.get_parent_ids()
if revision_id not in parent_ids:
@@ -1483,7 +1496,7 @@
def __init__(self, wt, revision_id, repository):
self._wt = wt
- # self._dirstate = dirstate
+ self._dirstate_at_creation = weakref.ref(wt._current_dirstate())
self._revision_id = revision_id
self._repository = repository
self._inventory = None
@@ -1777,7 +1790,17 @@
state = self._wt._current_dirstate()
if state._lock_token is None:
state.lock_read()
+ # TODO: this code path should probably be deprecated, but most
+ # likely it is caught by the next path
self._dirstate_locked = True
+ state_at_creation = self._dirstate_at_creation()
+ if state_at_creation is None or state is not state_at_creation:
+ symbol_versioning.warn('Caller failed to maintain lock'
+ ' on working tree for the lifetime of the'
+ ' DirStateRevisionTree returned by'
+ ' wt.basis_tree() or wt.revision_tree()'
+ ' This should always be done since bzr 1.12',
+ DeprecationWarning, stacklevel=2)
self._locked += 1
def _must_be_locked(self):
More information about the bazaar-commits
mailing list