Rev 6516: (jelmer) Add co: directory service. (Jelmer Vernooij) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Fri Mar 30 01:58:48 UTC 2012
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6516 [merge]
revision-id: pqm at pqm.ubuntu.com-20120330015847-a0usc8fbawzc1bu4
parent: pqm at pqm.ubuntu.com-20120330013338-d3vspfdtj6dvnc0c
parent: jelmer at samba.org-20120321132911-3rr9q3i9k1y8so14
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2012-03-30 01:58:47 +0000
message:
(jelmer) Add co: directory service. (Jelmer Vernooij)
modified:
bzrlib/directory_service.py directory_service.py-20080305221044-vr2mkvlsk8jypa2y-1
bzrlib/tests/test_directory_service.py test_directory_servi-20080305221044-vr2mkvlsk8jypa2y-2
doc/en/release-notes/bzr-2.6.txt bzr2.6.txt-20120116134316-8w1xxom1c7vcu1t5-1
=== modified file 'bzrlib/directory_service.py'
--- a/bzrlib/directory_service.py 2011-12-19 13:23:58 +0000
+++ b/bzrlib/directory_service.py 2012-03-21 13:22:09 +0000
@@ -30,6 +30,7 @@
lazy_import(globals(), """
from bzrlib import (
branch as _mod_branch,
+ controldir as _mod_controldir,
urlutils,
)
""")
@@ -131,3 +132,21 @@
directories.register(':', AliasDirectory,
'Easy access to remembered branch locations')
+
+
+class ColocatedDirectory(object):
+ """Directory lookup for colocated branches.
+
+ co:somename will resolve to the colocated branch with "somename" in
+ the current directory.
+ """
+
+ def look_up(self, name, url):
+ dir = _mod_controldir.ControlDir.open_containing('.')[0]
+ return urlutils.join_segment_parameters(dir.user_url,
+ {"branch": urlutils.escape(name)})
+
+
+directories.register('co:', ColocatedDirectory,
+ 'Easy access to colocated branches')
+
=== modified file 'bzrlib/tests/test_directory_service.py'
--- a/bzrlib/tests/test_directory_service.py 2012-01-18 14:09:19 +0000
+++ b/bzrlib/tests/test_directory_service.py 2012-03-21 13:29:11 +0000
@@ -116,3 +116,24 @@
AliasDirectory.branch_aliases.register("booga",
lambda b: "UHH?", help="Nobody knows")
self.assertEquals("UHH?", directories.dereference(":booga"))
+
+
+class TestColocatedDirectory(TestCaseWithTransport):
+
+ def test_lookup_non_default(self):
+ default = self.make_branch('.')
+ non_default = default.bzrdir.create_branch(name='nondefault')
+ self.assertEquals(non_default.base, directories.dereference('co:nondefault'))
+
+ def test_lookup_default(self):
+ default = self.make_branch('.')
+ non_default = default.bzrdir.create_branch(name='nondefault')
+ self.assertEquals(urlutils.join_segment_parameters(default.bzrdir.user_url,
+ {"branch": ""}), directories.dereference('co:'))
+
+ def test_no_such_branch(self):
+ # No error is raised in this case, that is up to the code that actually
+ # opens the branch.
+ default = self.make_branch('.')
+ self.assertEquals(urlutils.join_segment_parameters(default.bzrdir.user_url,
+ {"branch": "foo"}), directories.dereference('co:foo'))
=== modified file 'doc/en/release-notes/bzr-2.6.txt'
--- a/doc/en/release-notes/bzr-2.6.txt 2012-03-28 16:13:49 +0000
+++ b/doc/en/release-notes/bzr-2.6.txt 2012-03-30 01:58:47 +0000
@@ -26,6 +26,9 @@
.. Improvements to existing commands, especially improved performance
or memory usage, or better results.
+* Colocated branches can now be addressed using the 'co:NAME' rather than
+ the more complex 'file://.,branch=NAME'. (Jelmer Vernooij, #833665)
+
Bug Fixes
*********
More information about the bazaar-commits
mailing list