Rev 5355: update the test suite. in http://bazaar.launchpad.net/~jameinel/bzr/2.3-disable-accelerator-tree

John Arbash Meinel john at arbash-meinel.com
Tue Jul 20 11:18:11 BST 2010


At http://bazaar.launchpad.net/~jameinel/bzr/2.3-disable-accelerator-tree

------------------------------------------------------------
revno: 5355
revision-id: john at arbash-meinel.com-20100720101805-e13d09nnjywo3klb
parent: john at arbash-meinel.com-20100720091332-0y0yq151gsi7ebc0
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.3-disable-accelerator-tree
timestamp: Tue 2010-07-20 05:18:05 -0500
message:
  update the test suite.
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2010-07-20 09:13:32 +0000
+++ b/bzrlib/builtins.py	2010-07-20 10:18:05 +0000
@@ -1137,6 +1137,8 @@
     takes_args = ['from_location', 'to_location?']
     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',
@@ -1155,23 +1157,24 @@
                     ' allow branch to proceed.'),
         Option('bind',
             help="Bind new branch to from location."),
-        Option('use-accel', help='Try to copy content from the source tree'
-            ' rather than extracting it from the repository.'
-            ' Setting "--hardlink" forces this to True'),
         ]
     aliases = ['get', 'clone']
 
     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_accel=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)
-        use_accel = (hardlink or use_accel)
-        if not use_accel:
+        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:
@@ -1274,27 +1277,23 @@
                      Option('hardlink',
                             help='Hard-link working tree files where possible.'
                             ),
-                     Option('use-accel',
-                         help='Try to copy content from the source tree'
-                              ' rather than extracting it from the repository.'
-                              ' Setting "--hardlink" or "--files-from"'
-                              ' forces this to True'),
                      ]
     aliases = ['co']
 
     def run(self, branch_location=None, to_location=None, revision=None,
-            lightweight=False, files_from=None, hardlink=False,
-            use_accel=False):
+            lightweight=False, files_from=None, hardlink=False):
         if branch_location is None:
             branch_location = osutils.getcwd()
             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)
-        use_accel = (hardlink or use_accel or files_from)
-        if not use_accel:
-            accelerator_tree = None
-        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-20 10:18:05 +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.assertNotEqual(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