1
"""Custom URL Scheme - Create custom URL schemes for shortening URLS
3
Custom URL Scheme is a simple plugin for Bazaar, providing a means of
4
branching from remote servers without having to type out the full address
5
of the server. For example, if it is desirable to retrieve branches stored
6
on a server with sftp, you could shorten:
8
bzr branch sftp://my.username@server.com/path/to/bazaar/projects/work/myproj
12
bzr branch serv:work/myproj
14
In normal use, there are no required commands, but some commands are available
15
to simplify creation of url schemes:
17
* custom-url-scheme-add - Add a new URL scheme
18
* custom-url-scheme-list - List existing URL schemes
19
* custom-url-scheme-remove - Remove an existing URL scheme
21
Very little error checking is carried out at present.
24
version_info = (1,0,0)
3
26
from bzrlib.directory_service import directories
4
27
from bzrlib.config import GlobalConfig
9
32
'Custom URLScheme directory service',)
11
config = GlobalConfig()
12
parser = config._get_parser()
13
custom_schemes = parser.get('Custom URL Schemes', {})
14
for name, command in custom_schemes.items():
15
while name.endswith(':'):
17
_register_directory(name)
34
def GetCustomSchemes():
35
config = GlobalConfig()
36
parser = config._get_parser()
37
stored_custom_schemes = parser.get('Custom URL Schemes', {})
39
for name, command in stored_custom_schemes.items():
40
while name.endswith(':'):
42
custom_schemes[name] = command
45
def register_directories():
46
custom_schemes = GetCustomSchemes()
47
for name in custom_schemes.keys():
48
_register_directory(name)
50
register_directories()
52
from bzrlib.commands import plugin_cmds
54
# module, command, [aliases]
55
('bzrlib.plugins.custom_url_scheme.commands', 'cmd_custom_url_scheme_add', []),
56
('bzrlib.plugins.custom_url_scheme.commands', 'cmd_custom_url_scheme_list', []),
57
('bzrlib.plugins.custom_url_scheme.commands', 'cmd_custom_url_scheme_remove', []),
60
for module, name, aliases in lazy_commands:
61
plugin_cmds.register_lazy(name, aliases, module)