Rev 2950: * Revert takes out an appropriate lock when reverting to a basis tree, and in http://people.ubuntu.com/~robertc/baz2.0/revert
Robert Collins
robertc at robertcollins.net
Tue Oct 30 20:03:41 GMT 2007
At http://people.ubuntu.com/~robertc/baz2.0/revert
------------------------------------------------------------
revno: 2950
revision-id:robertc at robertcollins.net-20071030200323-2iyytqgqcltpngta
parent: pqm at pqm.ubuntu.com-20071029221703-zy7q7a0ehfvpybtn
committer: Robert Collins <robertc at robertcollins.net>
branch nick: revert
timestamp: Wed 2007-10-31 07:03:23 +1100
message:
* Revert takes out an appropriate lock when reverting to a basis tree, and
does not read the basis inventory twice. (Robert Collins)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
=== modified file 'NEWS'
--- a/NEWS 2007-10-29 04:05:13 +0000
+++ b/NEWS 2007-10-30 20:03:23 +0000
@@ -82,6 +82,9 @@
* Partial commits are now approximately 40% faster by walking over the
unselected current tree more efficiently. (Robert Collins)
+ * Revert takes out an appropriate lock when reverting to a basis tree, and
+ does not read the basis inventory twice. (Robert Collins)
+
* XML inventory serialisation takes 20% less time while being stricter about
the contents. (Robert Collins)
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py 2007-10-22 01:23:51 +0000
+++ b/bzrlib/workingtree.py 2007-10-30 20:03:23 +0000
@@ -1960,14 +1960,29 @@
' as of bzr 0.91. Please use None (the default) instead.',
DeprecationWarning, stacklevel=2)
if old_tree is None:
- old_tree = self.basis_tree()
- conflicts = transform.revert(self, old_tree, filenames, backups, pb,
- report_changes)
- if filenames is None:
- self.set_parent_ids(self.get_parent_ids()[:1])
- resolve(self)
+ basis_tree = self.basis_tree()
+ basis_tree.lock_read()
+ old_tree = basis_tree
else:
- resolve(self, filenames, ignore_misses=True)
+ basis_tree = None
+ try:
+ conflicts = transform.revert(self, old_tree, filenames, backups, pb,
+ report_changes)
+ if filenames is None:
+ parent_trees = []
+ last_revision = self.last_revision()
+ if last_revision != NULL_REVISION:
+ if basis_tree is None:
+ basis_tree = self.basis_tree()
+ basis_tree.lock_read()
+ parent_trees.append((last_revision, basis_tree))
+ self.set_parent_trees(parent_trees)
+ resolve(self)
+ else:
+ resolve(self, filenames, ignore_misses=True)
+ finally:
+ if basis_tree is not None:
+ basis_tree.unlock()
return conflicts
def revision_tree(self, revision_id):
More information about the bazaar-commits
mailing list