Rev 4869: (andrew) Allow '--hardlink' of files from 2a trees for any file that in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Dec 7 03:00:01 GMT 2009


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

------------------------------------------------------------
revno: 4869 [merge]
revision-id: pqm at pqm.ubuntu.com-20091207025958-wrddjbe59f5mjgva
parent: pqm at pqm.ubuntu.com-20091204231732-nbilalcmsekhl3li
parent: andrew.bennetts at canonical.com-20091204061325-8s0wghkp5if1ywiu
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2009-12-07 02:59:58 +0000
message:
  (andrew) Allow '--hardlink' of files from 2a trees for any file that
  	is unfiltered. (#408193)
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
  bzrlib/tests/per_tree/test_iter_search_rules.py test_iter_search_rul-20080528065532-1ml1ttb12az20cxf-1
  bzrlib/tests/test_transform.py test_transaction.py-20060105172520-b3ffb3946550e6c4
  bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
=== modified file 'NEWS'
--- a/NEWS	2009-12-04 22:13:52 +0000
+++ b/NEWS	2009-12-07 02:59:58 +0000
@@ -67,6 +67,10 @@
 * Terminate ssh subprocesses when no references to them remain, fixing
   subprocess and file descriptor leaks.  (Andrew Bennetts, #426662)
   
+* The ``--hardlink`` option of ``bzr branch`` and ``bzr checkout`` now
+  works for 2a format trees.  Only files unaffected by content filters
+  will be hardlinked.  (Andrew Bennetts, #408193)
+
 * The new glob expansion on Windows would replace all ``\`` characters
   with ``/`` even if it there wasn't a glob to expand, the arg was quoted,
   etc. Now only change slashes if there is something being glob expanded.

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-12-03 20:56:18 +0000
+++ b/bzrlib/builtins.py	2009-12-07 02:59:58 +0000
@@ -1209,9 +1209,6 @@
         from bzrlib.tag import _merge_tags_if_possible
         accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
             from_location)
-        if (accelerator_tree is not None and
-            accelerator_tree.supports_content_filtering()):
-            accelerator_tree = None
         revision = _get_one_revision('branch', revision)
         br_from.lock_read()
         try:

=== modified file 'bzrlib/tests/blackbox/test_branch.py'
--- a/bzrlib/tests/blackbox/test_branch.py	2009-08-20 12:30:49 +0000
+++ b/bzrlib/tests/blackbox/test_branch.py	2009-11-27 00:34:40 +0000
@@ -171,15 +171,7 @@
         out, err = self.run_bzr(['branch', 'source', 'target', '--hardlink'])
         source_stat = os.stat('source/file1')
         target_stat = os.stat('target/file1')
-        same_file = (source_stat == target_stat)
-        if same_file:
-            pass
-        else:
-            # https://bugs.edge.launchpad.net/bzr/+bug/408193
-            self.assertContainsRe(err, "hardlinking working copy files is "
-                "not currently supported")
-            raise KnownFailure("--hardlink doesn't work in formats "
-                "that support content filtering (#408193)")
+        self.assertEqual(source_stat, target_stat)
 
     def test_branch_standalone(self):
         shared_repo = self.make_repository('repo', shared=True)

=== modified file 'bzrlib/tests/blackbox/test_checkout.py'
--- a/bzrlib/tests/blackbox/test_checkout.py	2009-08-03 04:19:03 +0000
+++ b/bzrlib/tests/blackbox/test_checkout.py	2009-12-01 06:07:41 +0000
@@ -160,12 +160,4 @@
             '--hardlink'])
         source_stat = os.stat('source/file1')
         target_stat = os.stat('target/file1')
-        same_file = (source_stat == target_stat)
-        if same_file:
-            pass
-        else:
-            # https://bugs.edge.launchpad.net/bzr/+bug/408193
-            self.assertContainsRe(err, "hardlinking working copy files is "
-                "not currently supported")
-            raise KnownFailure("--hardlink doesn't work in formats "
-                "that support content filtering (#408193)")
+        self.assertEqual(source_stat, target_stat)

=== modified file 'bzrlib/tests/per_tree/test_iter_search_rules.py'
--- a/bzrlib/tests/per_tree/test_iter_search_rules.py	2009-07-10 07:14:02 +0000
+++ b/bzrlib/tests/per_tree/test_iter_search_rules.py	2009-12-03 05:21:09 +0000
@@ -18,7 +18,6 @@
 
 from bzrlib import (
     rules,
-    tests,
     )
 from bzrlib.tests.per_tree import TestCaseWithTree
 

=== modified file 'bzrlib/tests/test_transform.py'
--- a/bzrlib/tests/test_transform.py	2009-11-18 16:10:18 +0000
+++ b/bzrlib/tests/test_transform.py	2009-12-04 06:13:25 +0000
@@ -15,18 +15,18 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 import os
-import stat
 from StringIO import StringIO
 import sys
 
 from bzrlib import (
     bencode,
     errors,
+    filters,
     generate_ids,
     osutils,
     progress,
     revision as _mod_revision,
-    symbol_versioning,
+    rules,
     tests,
     urlutils,
     )
@@ -1868,6 +1868,49 @@
         self.assertEqual([], list(target.iter_changes(revision_tree)))
         self.assertTrue(source.is_executable('file1-id'))
 
+    def install_rot13_content_filter(self, pattern):
+        original_registry = filters._reset_registry()
+        def restore_registry():
+            filters._reset_registry(original_registry)
+        self.addCleanup(restore_registry)
+        def rot13(chunks, context=None):
+            return [''.join(chunks).encode('rot13')]
+        rot13filter = filters.ContentFilter(rot13, rot13)
+        filters.register_filter_stack_map('rot13', {'yes': [rot13filter]}.get)
+        os.mkdir(self.test_home_dir + '/.bazaar')
+        rules_filename = self.test_home_dir + '/.bazaar/rules'
+        f = open(rules_filename, 'wb')
+        f.write('[name %s]\nrot13=yes\n' % (pattern,))
+        f.close()
+        def uninstall_rules():
+            os.remove(rules_filename)
+            rules.reset_rules()
+        self.addCleanup(uninstall_rules)
+        rules.reset_rules()
+
+    def test_build_tree_content_filtered_files_are_not_hardlinked(self):
+        """build_tree will not hardlink files that have content filtering rules
+        applied to them (but will still hardlink other files from the same tree
+        if it can).
+        """
+        self.requireFeature(HardlinkFeature)
+        self.install_rot13_content_filter('file1')
+        source = self.create_ab_tree()
+        target = self.make_branch_and_tree('target')
+        revision_tree = source.basis_tree()
+        revision_tree.lock_read()
+        self.addCleanup(revision_tree.unlock)
+        build_tree(revision_tree, target, source, hardlink=True)
+        target.lock_read()
+        self.addCleanup(target.unlock)
+        self.assertEqual([], list(target.iter_changes(revision_tree)))
+        source_stat = os.stat('source/file1')
+        target_stat = os.stat('target/file1')
+        self.assertNotEqual(source_stat, target_stat)
+        source_stat = os.stat('source/file2')
+        target_stat = os.stat('target/file2')
+        self.assertEqualStat(source_stat, target_stat)
+
     def test_case_insensitive_build_tree_inventory(self):
         if (tests.CaseInsensitiveFilesystemFeature.available()
             or tests.CaseInsCasePresFilenameFeature.available()):

=== modified file 'bzrlib/transform.py'
--- a/bzrlib/transform.py	2009-12-03 02:24:54 +0000
+++ b/bzrlib/transform.py	2009-12-03 05:57:41 +0000
@@ -2300,8 +2300,12 @@
         new_desired_files = desired_files
     else:
         iter = accelerator_tree.iter_changes(tree, include_unchanged=True)
-        unchanged = dict((f, p[1]) for (f, p, c, v, d, n, k, e)
-                         in iter if not (c or e[0] != e[1]))
+        unchanged = [(f, p[1]) for (f, p, c, v, d, n, k, e)
+                     in iter if not (c or e[0] != e[1])]
+        if accelerator_tree.supports_content_filtering():
+            unchanged = [(f, p) for (f, p) in unchanged
+                         if not accelerator_tree.iter_search_rules([p]).next()]
+        unchanged = dict(unchanged)
         new_desired_files = []
         count = 0
         for file_id, (trans_id, tree_path) in desired_files:

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2009-11-14 11:06:51 +0000
+++ b/bzrlib/workingtree_4.py	2009-12-03 05:57:41 +0000
@@ -1447,21 +1447,10 @@
                 if basis_root_id is not None:
                     wt._set_root_id(basis_root_id)
                     wt.flush()
-                # If content filtering is supported, do not use the accelerator
-                # tree - the cost of transforming the content both ways and
-                # checking for changed content can outweight the gains it gives.
-                # Note: do NOT move this logic up higher - using the basis from
-                # the accelerator tree is still desirable because that can save
-                # a minute or more of processing on large trees!
-                # The original tree may not have the same content filters
-                # applied so we can't safely build the inventory delta from
-                # the source tree.
                 if wt.supports_content_filtering():
-                    if hardlink:
-                        # see https://bugs.edge.launchpad.net/bzr/+bug/408193
-                        trace.warning("hardlinking working copy files is not currently "
-                            "supported in %r" % (wt,))
-                    accelerator_tree = None
+                    # The original tree may not have the same content filters
+                    # applied so we can't safely build the inventory delta from
+                    # the source tree.
                     delta_from_tree = False
                 else:
                     delta_from_tree = True




More information about the bazaar-commits mailing list