Rev 2373: [merge] bzr.dev 2374 in http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/move_children_correctly

John Arbash Meinel john at arbash-meinel.com
Thu Mar 22 23:56:09 GMT 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/move_children_correctly

------------------------------------------------------------
revno: 2373
revision-id: john at arbash-meinel.com-20070322235549-q802rg14wurej850
parent: john at arbash-meinel.com-20070322234720-re8l7jtva8msgbsv
parent: pqm at pqm.ubuntu.com-20070322230820-f8735ba918f51539
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: move_children_correctly
timestamp: Thu 2007-03-22 18:55:49 -0500
message:
  [merge] bzr.dev 2374
added:
  bzrlib/tests/branch_implementations/test_create_checkout.py test_create_checkout-20070322193723-n2wkp1g03r0404di-1
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/branch_implementations/__init__.py __init__.py-20060123013057-b12a52c3f361daf4
  bzrlib/tests/test_branch.py    test_branch.py-20060116013032-97819aa07b8ab3b5
  bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 2371.1.3
    merged: pqm at pqm.ubuntu.com-20070322230820-f8735ba918f51539
    parent: pqm at pqm.ubuntu.com-20070322225147-c274f2efe3564edc
    parent: john at arbash-meinel.com-20070322200752-4b29yobz92a38tqp
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Thu 2007-03-22 23:08:20 +0000
    message:
      (John Arbash Meinel) bug #93854, 'bzr checkout' should create branches in the same format as the source.
        ------------------------------------------------------------
        revno: 2370.3.2
        merged: john at arbash-meinel.com-20070322200752-4b29yobz92a38tqp
        parent: john at arbash-meinel.com-20070322194159-fxl08l4zah9df24r
        committer: John Arbash Meinel <john at arbash-meinel.com>
        branch nick: checkout_uses_branch_format_93854
        timestamp: Thu 2007-03-22 15:07:52 -0500
        message:
          Use BzrDir.set_branch_format() rather than setting it directly.
        ------------------------------------------------------------
        revno: 2370.3.1
        merged: john at arbash-meinel.com-20070322194159-fxl08l4zah9df24r
        parent: pqm at pqm.ubuntu.com-20070321071219-55447700ec71371f
        committer: John Arbash Meinel <john at arbash-meinel.com>
        branch nick: checkout_uses_branch_format_93854
        timestamp: Thu 2007-03-22 14:41:59 -0500
        message:
          (John Arbash Meinel) Fix bug #93854, make 'bzr checkout' create branches in the same format as the source.
    ------------------------------------------------------------
    revno: 2371.1.2
    merged: pqm at pqm.ubuntu.com-20070322225147-c274f2efe3564edc
    parent: pqm at pqm.ubuntu.com-20070322213654-32f24e19910c30ef
    parent: john at arbash-meinel.com-20070322195543-2eo6deu0aynnstaq
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Thu 2007-03-22 22:51:47 +0000
    message:
      (John Arbash Meinel) Change WorkingTree to not read the inventory until we have a lock.
        ------------------------------------------------------------
        revno: 2334.1.6
        merged: john at arbash-meinel.com-20070322195543-2eo6deu0aynnstaq
        parent: john at arbash-meinel.com-20070322195430-wi92c7jpx17kiagr
        committer: John Arbash Meinel <john at arbash-meinel.com>
        branch nick: make_locking_cheaper
        timestamp: Thu 2007-03-22 14:55:43 -0500
        message:
          NEWS for performance fix.
        ------------------------------------------------------------
        revno: 2334.1.5
        merged: john at arbash-meinel.com-20070322195430-wi92c7jpx17kiagr
        parent: john at arbash-meinel.com-20070322151814-fs1m2j0inf8nu7w0
        parent: pqm at pqm.ubuntu.com-20070322152522-228285cac46c0dbc
        committer: John Arbash Meinel <john at arbash-meinel.com>
        branch nick: make_locking_cheaper
        timestamp: Thu 2007-03-22 14:54:30 -0500
        message:
          [merge] bzr.dev 2371
        ------------------------------------------------------------
        revno: 2334.1.4
        merged: john at arbash-meinel.com-20070322151814-fs1m2j0inf8nu7w0
        parent: john at arbash-meinel.com-20070321212157-3hmll50umf1nz1z3
        committer: John Arbash Meinel <john at arbash-meinel.com>
        branch nick: make_locking_cheaper
        timestamp: Thu 2007-03-22 10:18:14 -0500
        message:
          WT2 needs to have an _inventory without a lock.
        ------------------------------------------------------------
        revno: 2334.1.3
        merged: john at arbash-meinel.com-20070321212157-3hmll50umf1nz1z3
        parent: john at arbash-meinel.com-20070321181557-09nrfljkinlmyjmp
        committer: John Arbash Meinel <john at arbash-meinel.com>
        branch nick: make_locking_cheaper
        timestamp: Wed 2007-03-21 16:21:57 -0500
        message:
          When upgrading, we can't assume that WorkingTree._inventory is valid, because that is now
          done during tree.lock_*
        ------------------------------------------------------------
        revno: 2334.1.2
        merged: john at arbash-meinel.com-20070321181557-09nrfljkinlmyjmp
        parent: john at arbash-meinel.com-20070321175142-052tm470fx9s0obl
        committer: John Arbash Meinel <john at arbash-meinel.com>
        branch nick: make_locking_cheaper
        timestamp: Wed 2007-03-21 13:15:57 -0500
        message:
          we don't need _inventory_fp.
          
          The bug is that calling self.read_working_inventory() acquires a read lock,
          which has a side effect of reading the working inventory,
          and then it reads the working inventory,
          and then because the overall tree is not locked (this is all happening in WorkingTree.__init__)
          all of this is being thrown away.
          So we end up with 2 inventory reads which will be completely thrown away.
        ------------------------------------------------------------
        revno: 2334.1.1
        merged: john at arbash-meinel.com-20070321175142-052tm470fx9s0obl
        parent: pqm at pqm.ubuntu.com-20070310232535-dd964b3ad4a93236
        committer: John Arbash Meinel <john at arbash-meinel.com>
        branch nick: make_locking_cheaper
        timestamp: Wed 2007-03-21 12:51:42 -0500
        message:
          Lazily read working inventory in workingtree.py,
          this exposes code paths that are not locking the tree before
          processing, because they are directly accessing tree._inventory somehow
          (one case is Tree.path2id())
    ------------------------------------------------------------
    revno: 2371.1.1
    merged: pqm at pqm.ubuntu.com-20070322213654-32f24e19910c30ef
    parent: pqm at pqm.ubuntu.com-20070322152522-228285cac46c0dbc
    parent: john at arbash-meinel.com-20070322190703-qx2xft42j64hfp88
    committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
    branch nick: +trunk
    timestamp: Thu 2007-03-22 21:36:54 +0000
    message:
      (Matthew Fuller) Update 'bzr init-repo' help
    ------------------------------------------------------------
    revno: 2371.2.1
    merged: john at arbash-meinel.com-20070322190703-qx2xft42j64hfp88
    parent: pqm at pqm.ubuntu.com-20070322152522-228285cac46c0dbc
    parent: fullermd at over-yonder.net-20070321043951-0i5v9kc7tosonk9g
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: jam-integration
    timestamp: Thu 2007-03-22 14:07:03 -0500
    message:
      (Matthew Fuller) Update 'bzr init-repo' help
    ------------------------------------------------------------
    revno: 2366.1.2
    merged: fullermd at over-yonder.net-20070321043951-0i5v9kc7tosonk9g
    parent: fullermd at over-yonder.net-20070321040149-1c8b4mwco7llas7z
    committer: Matthew Fuller <fullermd at over-yonder.net>
    branch nick: init-repo-help
    timestamp: Tue 2007-03-20 23:39:51 -0500
    message:
      Shared-capable formats are standard, and have been for a good long
      while, so don't make a big deal of it in the help summary for
      init-repo.
    ------------------------------------------------------------
    revno: 2366.1.1
    merged: fullermd at over-yonder.net-20070321040149-1c8b4mwco7llas7z
    parent: pqm at pqm.ubuntu.com-20070320222307-30c846e90ac18c65
    committer: Matthew Fuller <fullermd at over-yonder.net>
    branch nick: init-repo-help
    timestamp: Tue 2007-03-20 23:01:49 -0500
    message:
      Missing space in --no-trees help.
-------------- next part --------------
=== added file 'bzrlib/tests/branch_implementations/test_create_checkout.py'
--- a/bzrlib/tests/branch_implementations/test_create_checkout.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/branch_implementations/test_create_checkout.py	2007-03-22 19:41:59 +0000
@@ -0,0 +1,66 @@
+# Copyright (C) 2007 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+"""Tests for the Branch.create_checkout"""
+
+from bzrlib import (
+    branch,
+    )
+from bzrlib.tests.branch_implementations.test_branch import TestCaseWithBranch
+
+
+class TestCreateCheckout(TestCaseWithBranch):
+
+    def test_checkout_format(self):
+        """Make sure the new checkout uses the same branch format."""
+        a_branch = self.make_branch('branch')
+        tree = a_branch.create_checkout('checkout')
+        if self.branch_format in branch._legacy_formats:
+            # Legacy formats create checkouts with the default format.
+            # Only newer formats create identical checkouts.
+            expected_format = branch.BranchFormat.get_default_format()
+        else:
+            expected_format = a_branch._format
+        self.assertEqual(expected_format.get_format_string(),
+                         tree.branch._format.get_format_string())
+
+    def test_create_revision_checkout(self):
+        """Test that we can create a checkout from an earlier revision."""
+        tree1 = self.make_branch_and_tree('base')
+        self.build_tree(['base/a'])
+        tree1.add(['a'], ['a-id'])
+        tree1.commit('first', rev_id='rev-1')
+        self.build_tree(['base/b'])
+        tree1.add(['b'], ['b-id'])
+        tree1.commit('second', rev_id='rev-2')
+
+        tree2 = tree1.branch.create_checkout('checkout', revision_id='rev-1')
+        self.assertEqual('rev-1', tree2.last_revision())
+        self.failUnlessExists('checkout/a')
+        self.failIfExists('checkout/b')
+
+    def test_create_lightweight_checkout(self):
+        """We should be able to make a lightweight checkout."""
+        tree1 = self.make_branch_and_tree('base')
+        tree2 = tree1.branch.create_checkout('checkout', lightweight=True)
+        self.assertNotEqual(tree1.basedir, tree2.basedir)
+        self.assertEqual(tree1.branch.base, tree2.branch.base)
+
+    def test_create_checkout_exists(self):
+        """We shouldn't fail if the directory already exists."""
+        tree1 = self.make_branch_and_tree('base')
+        self.build_tree('checkout')
+        tree2 = tree1.branch.create_checkout('checkout', lightweight=True)

=== modified file 'NEWS'
--- a/NEWS	2007-03-21 04:28:02 +0000
+++ b/NEWS	2007-03-22 23:08:20 +0000
@@ -8,6 +8,10 @@
       lock to an OS write lock. Linux can do this without unlocking, Win32
       needs to unlock in between. (John Arbash Meinel)
 
+    * Fix minor performance regression with bzr-0.15 on pre-dirstate
+      trees. (We were reading the working inventory too many times).
+      (John Arbash Meinel)
+
   BUGFIXES:
 
     * Take smtp_server from user config into account.
@@ -22,6 +26,9 @@
     * ``bzr status FILENAME`` failed on Windows because of an uncommon
       errno. (``ERROR_DIRECTORY == 267 != ENOTDIR``).
       (Wouter van Heyst, John Arbash Meinel, #90819)
+
+    * ``bzr checkout source`` should create a local branch in the same
+      format as source. (John Arbash Meinel, #93854)
  
 
 bzr 0.15rc2  2007-03-14

=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2007-03-13 01:00:34 +0000
+++ b/bzrlib/branch.py	2007-03-22 20:07:52 +0000
@@ -690,7 +690,7 @@
             format.repository_format = weaverepo.RepositoryFormat7()
         else:
             format = self.repository.bzrdir.checkout_metadir()
-            format.branch_format = self._format
+            format.set_branch_format(self._format)
         return format
 
     def create_checkout(self, to_location, revision_id=None,

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2007-03-19 07:26:06 +0000
+++ b/bzrlib/builtins.py	2007-03-21 04:39:51 +0000
@@ -1287,8 +1287,7 @@
     """Create a shared repository to hold branches.
 
     New branches created under the repository directory will store their revisions
-    in the repository, not in the branch directory, if the branch format supports
-    shared storage.
+    in the repository, not in the branch directory.
 
     example:
         bzr init-repo --no-trees repo
@@ -1307,7 +1306,7 @@
                             value_switches=True, title='Repository format'),
                      Option('no-trees',
                              help='Branches in the repository will default to'
-                                  'not having a working tree'),
+                                  ' not having a working tree'),
                     ]
     aliases = ["init-repo"]
 

=== modified file 'bzrlib/tests/branch_implementations/__init__.py'
--- a/bzrlib/tests/branch_implementations/__init__.py	2007-02-15 01:23:29 +0000
+++ b/bzrlib/tests/branch_implementations/__init__.py	2007-03-22 19:41:59 +0000
@@ -42,6 +42,7 @@
         'bzrlib.tests.branch_implementations.test_bound_sftp',
         'bzrlib.tests.branch_implementations.test_branch',
         'bzrlib.tests.branch_implementations.test_break_lock',
+        'bzrlib.tests.branch_implementations.test_create_checkout',
         'bzrlib.tests.branch_implementations.test_commit',
         'bzrlib.tests.branch_implementations.test_hooks',
         'bzrlib.tests.branch_implementations.test_http',

=== modified file 'bzrlib/tests/test_branch.py'
--- a/bzrlib/tests/test_branch.py	2007-03-14 03:42:40 +0000
+++ b/bzrlib/tests/test_branch.py	2007-03-22 19:41:59 +0000
@@ -175,13 +175,6 @@
         BranchFormat.unregister_format(format)
         self.make_branch_and_tree('bar')
 
-    def test_checkout_format(self):
-        branch = self.make_repository('repository', shared=True)
-        branch = self.make_branch('repository/branch',
-            format='metaweave')
-        tree = branch.create_checkout('checkout')
-        self.assertIs(tree.branch.__class__, _mod_branch.BzrBranch5)
-
 
 class TestBranch6(TestCaseWithTransport):
 

=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py	2007-03-07 03:09:14 +0000
+++ b/bzrlib/tree.py	2007-03-21 17:51:42 +0000
@@ -266,6 +266,7 @@
                      "file is actually %s" % fp['sha1'],
                      "store is probably damaged/corrupt"])
 
+    @needs_read_lock
     def path2id(self, path):
         """Return the id for path in this tree."""
         return self._inventory.path2id(path)

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2007-03-22 23:47:20 +0000
+++ b/bzrlib/workingtree.py	2007-03-22 23:55:49 +0000
@@ -277,8 +277,9 @@
             hc.write()
 
         if _inventory is None:
+            # This will be acquired on lock_read() or lock_write()
             self._inventory_is_modified = False
-            self.read_working_inventory()
+            self._inventory = None
         else:
             # the caller of __init__ has provided an inventory,
             # we assume they know what they are doing - as its only
@@ -2307,6 +2308,17 @@
      - uses the branch last-revision.
     """
 
+    def __init__(self, *args, **kwargs):
+        super(WorkingTree2, self).__init__(*args, **kwargs)
+        # WorkingTree2 has more of a constraint that self._inventory must
+        # exist. Because this is an older format, we don't mind the overhead
+        # caused by the extra computation here.
+
+        # Newer WorkingTree's should only have self._inventory set when they
+        # have a read lock.
+        if self._inventory is None:
+            self.read_working_inventory()
+
     def lock_tree_write(self):
         """See WorkingTree.lock_tree_write().
 

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-03-22 23:47:20 +0000
+++ b/bzrlib/workingtree_4.py	2007-03-22 23:55:49 +0000
@@ -2363,6 +2363,7 @@
         # tree during upgrade.
         tree._control_files.lock_write()
         try:
+            tree.read_working_inventory()
             self.create_dirstate_data(tree)
             self.update_format(tree)
             self.remove_xml_files(tree)



More information about the bazaar-commits mailing list