~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/directory_service.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-09-20 18:55:08 UTC
  • mfrom: (3714.2.4 bzr.ab.integration2)
  • Revision ID: pqm@pqm.ubuntu.com-20080920185508-g6uoij1vgokthw5m
Location aliases now accept a trailing path (mwhudson)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
from bzrlib import errors, registry
24
24
from bzrlib.branch import Branch
 
25
from bzrlib import urlutils
 
26
 
25
27
 
26
28
class DirectoryServiceRegistry(registry.Registry):
27
29
    """This object maintains and uses a list of directory services.
72
74
            'push': branch.get_push_location,
73
75
            'this': lambda: branch.base
74
76
        }
 
77
        parts = url.split('/', 1)
 
78
        if len(parts) == 2:
 
79
            name, extra = parts
 
80
        else:
 
81
            (name,) = parts
 
82
            extra = None
75
83
        try:
76
 
            method = lookups[url[1:]]
 
84
            method = lookups[name[1:]]
77
85
        except KeyError:
78
86
            raise errors.InvalidLocationAlias(url)
79
87
        else:
80
88
            result = method()
81
89
        if result is None:
82
90
            raise errors.UnsetLocationAlias(url)
 
91
        if extra is not None:
 
92
            result = urlutils.join(result, extra)
83
93
        return result
84
94
 
85
95
directories.register(':', AliasDirectory,