20
20
to true URLs. Examples include lp:urls and per-user location aliases.
23
from bzrlib import registry
23
from bzrlib import errors, registry
24
from bzrlib.branch import Branch
25
26
class DirectoryServiceRegistry(registry.Registry):
26
27
"""This object maintains and uses a list of directory services.
52
53
return service().look_up(name, url)
54
55
directories = DirectoryServiceRegistry()
58
class AliasDirectory(object):
59
"""Directory lookup for locations associated with a branch.
61
:parent, :submit, :public, :push, :this, and :bound are currently
62
supported. On error, a subclass of DirectoryLookupFailure will be raised.
65
def look_up(self, name, url):
66
branch = Branch.open_containing('.')[0]
68
'parent': branch.get_parent,
69
'submit': branch.get_submit_branch,
70
'public': branch.get_public_branch,
71
'bound': branch.get_bound_location,
72
'push': branch.get_push_location,
73
'this': lambda: branch.base
76
method = lookups[url[1:]]
78
raise errors.InvalidLocationAlias(url)
82
raise errors.UnsetLocationAlias(url)
85
directories.register(':', AliasDirectory,
86
'Easy access to remembered branch locations')