72
73
supported. On error, a subclass of DirectoryLookupFailure will be raised.
76
branch_aliases = registry.Registry()
77
branch_aliases.register('parent', lambda b: b.get_parent(),
78
help="The parent of this branch.")
79
branch_aliases.register('submit', lambda b: b.get_submit_branch(),
80
help="The submit branch for this branch.")
81
branch_aliases.register('public', lambda b: b.get_public_branch(),
82
help="The public location of this branch.")
83
branch_aliases.register('bound', lambda b: b.get_bound_location(),
84
help="The branch this branch is bound to, for bound branches.")
85
branch_aliases.register('push', lambda b: b.get_push_location(),
86
help="The saved location used for `bzr push` with no arguments.")
87
branch_aliases.register('this', lambda b: b.base,
75
90
def look_up(self, name, url):
76
91
branch = _mod_branch.Branch.open_containing('.')[0]
78
'parent': branch.get_parent,
79
'submit': branch.get_submit_branch,
80
'public': branch.get_public_branch,
81
'bound': branch.get_bound_location,
82
'push': branch.get_push_location,
83
'this': lambda: branch.base
85
92
parts = url.split('/', 1)
86
93
if len(parts) == 2:
87
94
name, extra = parts
92
method = lookups[name[1:]]
99
method = self.branch_aliases.get(name[1:])
94
101
raise errors.InvalidLocationAlias(url)
103
result = method(branch)
97
104
if result is None:
98
105
raise errors.UnsetLocationAlias(url)
99
106
if extra is not None:
100
107
result = urlutils.join(result, extra)
111
def help_text(cls, topic):
113
for key in cls.branch_aliases.keys():
114
help = cls.branch_aliases.get_help(key)
115
alias_lines.append(" :%-10s%s\n" % (key, help))
120
Bazaar defines several aliases for locations associated with a branch. These
121
can be used with most commands that expect a location, such as `bzr push`.
126
For example, to push to the parent location::
129
""" % "".join(alias_lines)
103
132
directories.register(':', AliasDirectory,
104
133
'Easy access to remembered branch locations')