15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
18
from StringIO import StringIO
22
21
from bzrlib import (
28
28
revision as _mod_revision,
1868
1868
self.assertEqual([], list(target.iter_changes(revision_tree)))
1869
1869
self.assertTrue(source.is_executable('file1-id'))
1871
def install_rot13_content_filter(self, pattern):
1872
original_registry = filters._reset_registry()
1873
def restore_registry():
1874
filters._reset_registry(original_registry)
1875
self.addCleanup(restore_registry)
1876
def rot13(chunks, context=None):
1877
return [''.join(chunks).encode('rot13')]
1878
rot13filter = filters.ContentFilter(rot13, rot13)
1879
filters.register_filter_stack_map('rot13', {'yes': [rot13filter]}.get)
1880
os.mkdir(self.test_home_dir + '/.bazaar')
1881
rules_filename = self.test_home_dir + '/.bazaar/rules'
1882
f = open(rules_filename, 'wb')
1883
f.write('[name %s]\nrot13=yes\n' % (pattern,))
1885
def uninstall_rules():
1886
os.remove(rules_filename)
1888
self.addCleanup(uninstall_rules)
1891
def test_build_tree_content_filtered_files_are_not_hardlinked(self):
1892
"""build_tree will not hardlink files that have content filtering rules
1893
applied to them (but will still hardlink other files from the same tree
1896
self.requireFeature(HardlinkFeature)
1897
self.install_rot13_content_filter('file1')
1898
source = self.create_ab_tree()
1899
target = self.make_branch_and_tree('target')
1900
revision_tree = source.basis_tree()
1901
revision_tree.lock_read()
1902
self.addCleanup(revision_tree.unlock)
1903
build_tree(revision_tree, target, source, hardlink=True)
1905
self.addCleanup(target.unlock)
1906
self.assertEqual([], list(target.iter_changes(revision_tree)))
1907
source_stat = os.stat('source/file1')
1908
target_stat = os.stat('target/file1')
1909
self.assertNotEqual(source_stat, target_stat)
1910
source_stat = os.stat('source/file2')
1911
target_stat = os.stat('target/file2')
1912
self.assertEqualStat(source_stat, target_stat)
1871
1914
def test_case_insensitive_build_tree_inventory(self):
1872
1915
if (tests.CaseInsensitiveFilesystemFeature.available()
1873
1916
or tests.CaseInsCasePresFilenameFeature.available()):