[MERGE] Nested trees: Store tree-reference locations in the branch.

Aaron Bentley aaron at aaronbentley.com
Thu Apr 23 18:12:26 BST 2009


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

Ian Clatworthy wrote:
> Aaron Bentley wrote:
>> I haven't yet implemented the "reference-location" command, but I intend
>> to do so.  It will be similar to the alias command, providing a way to
>> list, view and set reference locations.
> 
> I think calling it simple "reference" would be fine.

I'm certainly not stuck on a name.

> BTW, we're not fully consistent here. We have:
> 
> * case where we have multiple commands, e.g. tag & tags
> * cases where we use just one command, e.g. alias
> * cases where the single command lists the active thing and --all
>   is needed to display all things, e.g. view.
> * cases where only the list aspect is supported, e.g. plugins.

I'm open to other ideas, I just thought it was analogous to aliases.
But you're right about the tags analogy.

>> +    def initialize(self, a_bzrdir):
>> +        """Create a branch of this format in a_bzrdir."""
>> +        utf8_files = [('last-revision', '0 null:\n'),
>> +                      ('branch.conf', ''),
>> +                      ('tags', ''),
>> +                      ('references', '')
>> +                      ]
>> +        return self._initialize_helper(a_bzrdir, utf8_files)
> 
> I suspect you need to also define and register a simple converter
> from format7 to format8 that initialises an empty references file.

Done.

>> +    def _get_all_reference_info(self):
>> +        """Return all the reference info stored in a branch.
>> +
>> +        :return: A dict of {file_id: (tree_path, branch_location)}
>> +        """
>> +        rio_file = self._transport.get('references')
>> +        try:
>> +            stanzas = rio.read_stanzas(rio_file)
>> +            info_dict = dict((s['file_id'], (s['tree_path'],
>> +                             s['branch_location'])) for s in stanzas)
>> +        finally:
>> +            rio_file.close()
>> +        return info_dict
> 
> Is it worth caching this dict in a branch attribute? Getting it from
> disk every time seems unnecessary.

I was just focusing on getting the API right.  I've gone and added caching.

>> +    def update_references_skips_known_references(self):
>> +        branch = self.make_branch_with_reference('branch', 'reference')
>> +        new_branch = branch.bzrdir.sprout('branch/new-branch').open_branch()
>> +        new_branch.set_reference_info('file-id', '../foo', '../foo')
>> +        new_branch.update_references(branch)
>> +        self.assertEqual('../reference',
>> +                         branch.get_reference_info('file-id')[1])
> 
> This doesn't seem to be used anywhere as a helper method. I suspect you
> meant to put test_ at the front of the method name.

Yes.  I actually removed the test_ to "temporarily" disable it.

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

iEYEARECAAYFAknwoXcACgkQ0F+nu1YWqI0g6ACfbK5BxAE+0y2WgGtjsreaS4Pg
isEAnjiOf/zJSDrxLJascSs+am4pH26f
=elBD
-----END PGP SIGNATURE-----



More information about the bazaar mailing list