[MERGE] Allow appending path segments to the :<name> style aliases.
Michael Hudson
michael.hudson at canonical.com
Thu Aug 14 04:16:38 BST 2008
John Arbash Meinel wrote:
> Michael Hudson wrote:
>> This simple patch extends the directory service to allow path segments
>> after the name of a branch location alias. For example you could do
>> this in a lightweight checkout of a loom to push a non-loomified version
>> of the current thread of the loom to its default location:
>
>> bzr export-loom :this; bzr push -d :this/`bzr nick`
>
>> Cheers,
>> mwh
>
>
> + if '/' in url:
> + name = url[1:url.find('/')]
> + extra = url[url.find('/') + 1:]
> + else:
> + name = url[1:]
> + extra = None
>
> ^- This seems like a really inefficient way of saying:
>
> name, extra = url[1:].split('/', 1)
Um... no?
>>> ':this'.split('/', 1)
[':this']
What I wrote may be verbose and lack cuteness, but I was delibarately
going for obvious correctness :)
> -
> +from bzrlib.urlutils import join
>
> class FooService(object):
> """A directory service that maps the name to a FILE url"""
> @@ -83,6 +83,11 @@
> branch = self.make_branch('.')
> self.assertEqual(branch.base, directories.dereference(':this'))
>
> + def test_extra_path(self):
> + branch = self.make_branch('.')
> + self.assertEqual(
> + join(branch.base, 'arg'), directories.dereference(':this/arg'))
>
> ^- I'd really rather see
>
> from bzrlib import urlutils
>
> ...
> self.assertEqual(urlutils.join(branch.base, 'arg'),
> ...)
>
> A raw 'join()' function with no context could be a lot of different functions.
Sure. I changed it in directory_service.py too. Update attached.
> BB:tweak
Thanks.
Cheers,
mwh
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: extend-alias-locations-progress.bundle
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20080814/727e4423/attachment.diff
More information about the bazaar
mailing list