~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/directory_service.py

  • Committer: Jelmer Vernooij
  • Date: 2012-03-21 13:22:09 UTC
  • mto: This revision was merged to the branch mainline in revision 6516.
  • Revision ID: jelmer@samba.org-20120321132209-5ztjbiwn4cs0t5az
Add 'co:' directory service.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
lazy_import(globals(), """
31
31
from bzrlib import (
32
32
    branch as _mod_branch,
 
33
    controldir as _mod_controldir,
33
34
    urlutils,
34
35
    )
35
36
""")
131
132
 
132
133
directories.register(':', AliasDirectory,
133
134
                     'Easy access to remembered branch locations')
 
135
 
 
136
 
 
137
class ColocatedDirectory(object):
 
138
    """Directory lookup for colocated branches.
 
139
 
 
140
    co:somename will resolve to the colocated branch with "somename" in
 
141
    the current directory.
 
142
    """
 
143
 
 
144
    def look_up(self, name, url):
 
145
        dir = _mod_controldir.ControlDir.open_containing('.')[0]
 
146
        return urlutils.join_segment_parameters(dir.user_url,
 
147
            {"branch": urlutils.escape(name)})
 
148
 
 
149
 
 
150
directories.register('co:', ColocatedDirectory,
 
151
                     'Easy access to colocated branches')
 
152