~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/directory_service.py

  • Committer: Michael Hudson
  • Date: 2008-08-13 23:42:32 UTC
  • mto: (3714.2.1 bzr.ab.integration2)
  • mto: This revision was merged to the branch mainline in revision 3717.
  • Revision ID: michael.hudson@canonical.com-20080813234232-nzwpyo7u42zrkom5
Allow appending path segments to the :<name> style aliases.

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.urlutils import join
25
26
 
26
27
class DirectoryServiceRegistry(registry.Registry):
27
28
    """This object maintains and uses a list of directory services.
72
73
            'push': branch.get_push_location,
73
74
            'this': lambda: branch.base
74
75
        }
 
76
        if '/' in url:
 
77
            name = url[1:url.find('/')]
 
78
            extra = url[url.find('/') + 1:]
 
79
        else:
 
80
            name = url[1:]
 
81
            extra = None
75
82
        try:
76
 
            method = lookups[url[1:]]
 
83
            method = lookups[name]
77
84
        except KeyError:
78
85
            raise errors.InvalidLocationAlias(url)
79
86
        else:
80
87
            result = method()
81
88
        if result is None:
82
89
            raise errors.UnsetLocationAlias(url)
 
90
        if extra is not None:
 
91
            result = join(result, extra)
83
92
        return result
84
93
 
85
94
directories.register(':', AliasDirectory,