[MERGE] Even faster branching

Aaron Bentley aaron.bentley at utoronto.ca
Thu Dec 20 16:58:58 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Westby wrote:
> On (19/12/07 13:21), Aaron Bentley wrote:
> 
>> +    def test_build_tree_accelerator_tree(self):
>> +        source = self.make_branch_and_tree('source')
>> +        self.build_tree_contents([('source/file1', 'A')])
>> +        self.build_tree_contents([('source/file2', 'B')])
>> +        source.add(['file1', 'file2'], ['file1-id', 'file2-id'])
>> +        source.commit('commit files')
>> +        self.build_tree_contents([('source/file2', 'C')])
>> +        calls = []
>> +        real_source_get_file = source.get_file
>> +        def get_file(file_id, path=None):
>> +            calls.append(file_id)
>> +            return real_source_get_file(file_id, path)
>> +        source.get_file = get_file
>> +        source.lock_read()
>> +        self.addCleanup(source.unlock)
>> +        target = self.make_branch_and_tree('target')
>> +        build_tree(source.basis_tree(), target, source)
>> +        self.assertEqual(['file1-id'], calls)

> It appears there is no test with a tree being created that will contain
> a file that has been modified in the source tree, is that correct?

No.  In test_build_tree_accelerator_tree, file2 is modified
(self.build_tree_contents([('source/file2', 'C')])), and we check to
make sure it's not read from the source tree.

> I would think that it would be important to have a test for that situation
> that ensures that the contents of the file are correct in the new tree.

I've also added a check to all tests to ensure that the tree contents
are identical between target and source.basis_tree().

> Also there are no tests for symlinks and directories. I would think they
> would be important for regression purposes. Symlink issues seem to have
> regressed a couple of times.

The code deals only with creating regular files, because they are the
only ones that need to be special-cased for speed.  directories and
symlinks are handled much earlier in _build_tree.

I have added a test to ensure that if files are turned into symlinks or
directories in the accelerator tree, the accelerator tree isn't used to
obtain these files.  This seems a bit paranoid to me, because
_iter_changes will always consider content modified if the file kind has
changed.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHap9S0F+nu1YWqI0RAmC4AJ9MDPfq8Co59h40w2gp5nWM+09wDQCeL6+r
LyDGDmlW/5OnBBrNwSaJV2g=
=nz8P
-----END PGP SIGNATURE-----



More information about the bazaar mailing list