Rev 5358: (jam) Prefer to create content from the repo than from another in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Jul 21 23:29:49 BST 2010


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

------------------------------------------------------------
revno: 5358 [merge]
revision-id: pqm at pqm.ubuntu.com-20100721222945-ryovxiywq78nfukm
parent: pqm at pqm.ubuntu.com-20100721145413-0t39loftbuv8yk2f
parent: john at arbash-meinel.com-20100721200934-ri3rawaz2dir6f95
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2010-07-21 23:29:45 +0100
message:
  (jam) Prefer to create content from the repo than from another
  	working tree. (bug #607298)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_branch.py test_branch.py-20060524161337-noms9gmcwqqrfi8y-1
  bzrlib/tests/blackbox/test_checkout.py test_checkout.py-20060211231752-a5cde67cf70af854
=== modified file 'NEWS'
--- a/NEWS	2010-07-21 10:13:35 +0000
+++ b/NEWS	2010-07-21 22:29:45 +0000
@@ -47,6 +47,13 @@
 Improvements
 ************
 
+* When building new working trees, default to reading from the repository
+  rather than the source tree unless explicitly requested. (via
+  ``--files-from`` and ``--hardlink`` for ``bzr branch`` and
+  ``bzr checkout``. Generally, 2a format repositories extract
+  content faster than seeking and reading content from another tree,
+  especially in cold-cache situations. (John Arbash Meinel, #607298)
+
 Documentation
 *************
 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2010-07-19 15:39:51 +0000
+++ b/bzrlib/builtins.py	2010-07-20 10:18:05 +0000
@@ -1135,8 +1135,10 @@
 
     _see_also = ['checkout']
     takes_args = ['from_location', 'to_location?']
-    takes_options = ['revision', Option('hardlink',
-        help='Hard-link working tree files where possible.'),
+    takes_options = ['revision',
+        Option('hardlink', help='Hard-link working tree files where possible.'),
+        Option('files-from', type=str,
+               help="Get file contents from this tree."),
         Option('no-tree',
             help="Create a branch without a working-tree."),
         Option('switch',
@@ -1160,11 +1162,19 @@
 
     def run(self, from_location, to_location=None, revision=None,
             hardlink=False, stacked=False, standalone=False, no_tree=False,
-            use_existing_dir=False, switch=False, bind=False):
+            use_existing_dir=False, switch=False, bind=False,
+            files_from=None):
         from bzrlib import switch as _mod_switch
         from bzrlib.tag import _merge_tags_if_possible
         accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
             from_location)
+        if not (hardlink or files_from):
+            # accelerator_tree is usually slower because you have to read N
+            # files (no readahead, lots of seeks, etc), but allow the user to
+            # explicitly request it
+            accelerator_tree = None
+        if files_from is not None and files_from != from_location:
+            accelerator_tree = WorkingTree.open(files_from)
         revision = _get_one_revision('branch', revision)
         self.add_cleanup(br_from.lock_read().unlock)
         if revision is not None:
@@ -1277,8 +1287,13 @@
             to_location = branch_location
         accelerator_tree, source = bzrdir.BzrDir.open_tree_or_branch(
             branch_location)
+        if not (hardlink or files_from):
+            # accelerator_tree is usually slower because you have to read N
+            # files (no readahead, lots of seeks, etc), but allow the user to
+            # explicitly request it
+            accelerator_tree = None
         revision = _get_one_revision('checkout', revision)
-        if files_from is not None:
+        if files_from is not None and files_from != branch_location:
             accelerator_tree = WorkingTree.open(files_from)
         if revision is not None:
             revision_id = revision.as_revision_id(source)

=== modified file 'bzrlib/tests/blackbox/test_branch.py'
--- a/bzrlib/tests/blackbox/test_branch.py	2010-06-11 07:32:12 +0000
+++ b/bzrlib/tests/blackbox/test_branch.py	2010-07-21 20:09:34 +0000
@@ -174,6 +174,29 @@
         target_stat = os.stat('target/file1')
         self.assertEqual(source_stat, target_stat)
 
+    def test_branch_files_from(self):
+        source = self.make_branch_and_tree('source')
+        self.build_tree(['source/file1'])
+        source.add('file1')
+        source.commit('added file')
+        out, err = self.run_bzr('branch source target --files-from source')
+        self.failUnlessExists('target/file1')
+
+    def test_branch_files_from_hardlink(self):
+        self.requireFeature(HardlinkFeature)
+        source = self.make_branch_and_tree('source')
+        self.build_tree(['source/file1'])
+        source.add('file1')
+        source.commit('added file')
+        source.bzrdir.sprout('second')
+        out, err = self.run_bzr('branch source target --files-from second'
+                                ' --hardlink')
+        source_stat = os.stat('source/file1')
+        second_stat = os.stat('second/file1')
+        target_stat = os.stat('target/file1')
+        self.assertNotEqual(source_stat, target_stat)
+        self.assertEqual(second_stat, target_stat)
+
     def test_branch_standalone(self):
         shared_repo = self.make_repository('repo', shared=True)
         self.example_branch('source')

=== modified file 'bzrlib/tests/blackbox/test_checkout.py'
--- a/bzrlib/tests/blackbox/test_checkout.py	2010-06-11 07:32:12 +0000
+++ b/bzrlib/tests/blackbox/test_checkout.py	2010-07-20 10:18:05 +0000
@@ -156,9 +156,20 @@
         self.build_tree(['source/file1'])
         source.add('file1')
         source.commit('added file')
-        out, err = self.run_bzr(['checkout', 'source', 'target',
-            '--files-from', 'source',
-            '--hardlink'])
+        out, err = self.run_bzr('checkout source target --hardlink')
         source_stat = os.stat('source/file1')
         target_stat = os.stat('target/file1')
         self.assertEqual(source_stat, target_stat)
+
+    def test_checkout_hardlink_files_from(self):
+        self.requireFeature(HardlinkFeature)
+        source = self.make_branch_and_tree('source')
+        self.build_tree(['source/file1'])
+        source.add('file1')
+        source.commit('added file')
+        source.bzrdir.sprout('second')
+        out, err = self.run_bzr('checkout source target --hardlink'
+                                ' --files-from second')
+        second_stat = os.stat('second/file1')
+        target_stat = os.stat('target/file1')
+        self.assertEqual(second_stat, target_stat)




More information about the bazaar-commits mailing list