Rev 2951: (robertc) Stop reading the basis inventory from the repository twice during revert and manage basis tree locks better. (Robert Collins) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Oct 30 21:46:15 GMT 2007


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 2951
revision-id: pqm at pqm.ubuntu.com-20071030214613-c0ojrpmnm21da068
parent: pqm at pqm.ubuntu.com-20071030203434-6ffpvdncd12ncx3d
parent: robertc at robertcollins.net-20071030200323-2iyytqgqcltpngta
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2007-10-30 21:46:13 +0000
message:
  (robertc) Stop reading the basis inventory from the repository twice during revert and manage basis tree locks better. (Robert Collins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
    ------------------------------------------------------------
    revno: 2949.2.1
    merged: 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 file 'NEWS'
--- a/NEWS	2007-10-30 17:39:11 +0000
+++ b/NEWS	2007-10-30 21:46:13 +0000
@@ -85,6 +85,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