Merge lp:~jelmer/bzr/co-directory-service into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 6516
Proposed branch: lp:~jelmer/bzr/co-directory-service
Merge into: lp:bzr
Diff against target: 140 lines (+48/-7)
4 files modified
bzrlib/directory_service.py (+19/-0)
bzrlib/tests/test_directory_service.py (+21/-0)
bzrlib/tests/test_mergetools.py (+5/-7)
doc/en/release-notes/bzr-2.6.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/bzr/co-directory-service
Reviewer Review Type Date Requested Status
Vincent Ladeuil Needs Fixing
Review via email: mp+98629@code.launchpad.net

Commit message

Add co: directory service.

Description of the change

Add the 'co:' directory service.

This allows addressing colocated branches with a somewhat easier syntax,
instead of the frustratingly long "file:.,branch=NAME".

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

What's new worthy !

Could you make 'co:' appear in some 'bzr help' output ?

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/directory_service.py'
--- bzrlib/directory_service.py 2011-12-19 13:23:58 +0000
+++ bzrlib/directory_service.py 2012-03-21 13:34:24 +0000
@@ -30,6 +30,7 @@
30lazy_import(globals(), """30lazy_import(globals(), """
31from bzrlib import (31from bzrlib import (
32 branch as _mod_branch,32 branch as _mod_branch,
33 controldir as _mod_controldir,
33 urlutils,34 urlutils,
34 )35 )
35""")36""")
@@ -131,3 +132,21 @@
131132
132directories.register(':', AliasDirectory,133directories.register(':', AliasDirectory,
133 'Easy access to remembered branch locations')134 'Easy access to remembered branch locations')
135
136
137class 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
150directories.register('co:', ColocatedDirectory,
151 'Easy access to colocated branches')
152
134153
=== modified file 'bzrlib/tests/test_directory_service.py'
--- bzrlib/tests/test_directory_service.py 2012-01-18 14:09:19 +0000
+++ bzrlib/tests/test_directory_service.py 2012-03-21 13:34:24 +0000
@@ -116,3 +116,24 @@
116 AliasDirectory.branch_aliases.register("booga",116 AliasDirectory.branch_aliases.register("booga",
117 lambda b: "UHH?", help="Nobody knows")117 lambda b: "UHH?", help="Nobody knows")
118 self.assertEquals("UHH?", directories.dereference(":booga"))118 self.assertEquals("UHH?", directories.dereference(":booga"))
119
120
121class TestColocatedDirectory(TestCaseWithTransport):
122
123 def test_lookup_non_default(self):
124 default = self.make_branch('.')
125 non_default = default.bzrdir.create_branch(name='nondefault')
126 self.assertEquals(non_default.base, directories.dereference('co:nondefault'))
127
128 def test_lookup_default(self):
129 default = self.make_branch('.')
130 non_default = default.bzrdir.create_branch(name='nondefault')
131 self.assertEquals(urlutils.join_segment_parameters(default.bzrdir.user_url,
132 {"branch": ""}), directories.dereference('co:'))
133
134 def test_no_such_branch(self):
135 # No error is raised in this case, that is up to the code that actually
136 # opens the branch.
137 default = self.make_branch('.')
138 self.assertEquals(urlutils.join_segment_parameters(default.bzrdir.user_url,
139 {"branch": "foo"}), directories.dereference('co:foo'))
119140
=== modified file 'bzrlib/tests/test_mergetools.py'
--- bzrlib/tests/test_mergetools.py 2012-02-28 04:58:14 +0000
+++ bzrlib/tests/test_mergetools.py 2012-03-21 13:34:24 +0000
@@ -15,7 +15,6 @@
15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1616
17import os17import os
18import re
19import sys18import sys
20import tempfile19import tempfile
2120
@@ -23,7 +22,6 @@
23 mergetools,22 mergetools,
24 tests23 tests
25)24)
26from bzrlib.tests.features import backslashdir_feature
2725
2826
29class TestFilenameSubstitution(tests.TestCaseInTempDir):27class TestFilenameSubstitution(tests.TestCaseInTempDir):
@@ -39,7 +37,7 @@
39 '-o',37 '-o',
40 'test.txt'],38 'test.txt'],
41 args)39 args)
42 40
43 def test_spaces(self):41 def test_spaces(self):
44 cmd_list = ['kdiff3', '{base}', '{this}', '{other}', '-o', '{result}']42 cmd_list = ['kdiff3', '{base}', '{this}', '{other}', '-o', '{result}']
45 args, tmpfile = mergetools._subst_filename(cmd_list,43 args, tmpfile = mergetools._subst_filename(cmd_list,
@@ -107,7 +105,7 @@
107 ('test.txt.THIS', 'this stuff'),105 ('test.txt.THIS', 'this stuff'),
108 ('test.txt.OTHER', 'other stuff'),106 ('test.txt.OTHER', 'other stuff'),
109 ))107 ))
110 108
111 def test_invoke_expands_exe_path(self):109 def test_invoke_expands_exe_path(self):
112 self.overrideEnv('PATH', os.path.dirname(sys.executable))110 self.overrideEnv('PATH', os.path.dirname(sys.executable))
113 def dummy_invoker(exe, args, cleanup):111 def dummy_invoker(exe, args, cleanup):
@@ -120,7 +118,7 @@
120 self.assertEqual(0, retcode)118 self.assertEqual(0, retcode)
121 self.assertEqual(sys.executable, self._exe)119 self.assertEqual(sys.executable, self._exe)
122 self.assertEqual(['test.txt'], self._args)120 self.assertEqual(['test.txt'], self._args)
123 121
124 def test_success(self):122 def test_success(self):
125 def dummy_invoker(exe, args, cleanup):123 def dummy_invoker(exe, args, cleanup):
126 self._exe = exe124 self._exe = exe
@@ -131,7 +129,7 @@
131 self.assertEqual(0, retcode)129 self.assertEqual(0, retcode)
132 self.assertEqual('tool', self._exe)130 self.assertEqual('tool', self._exe)
133 self.assertEqual(['test.txt'], self._args)131 self.assertEqual(['test.txt'], self._args)
134 132
135 def test_failure(self):133 def test_failure(self):
136 def dummy_invoker(exe, args, cleanup):134 def dummy_invoker(exe, args, cleanup):
137 self._exe = exe135 self._exe = exe
@@ -159,7 +157,7 @@
159 self.assertEqual('tool', self._exe)157 self.assertEqual('tool', self._exe)
160 self.assertPathDoesNotExist(self._args[0])158 self.assertPathDoesNotExist(self._args[0])
161 self.assertFileEqual('temp stuff', 'test.txt')159 self.assertFileEqual('temp stuff', 'test.txt')
162 160
163 def test_failure_tempfile(self):161 def test_failure_tempfile(self):
164 def dummy_invoker(exe, args, cleanup):162 def dummy_invoker(exe, args, cleanup):
165 self._exe = exe163 self._exe = exe
166164
=== modified file 'doc/en/release-notes/bzr-2.6.txt'
--- doc/en/release-notes/bzr-2.6.txt 2012-03-16 15:05:05 +0000
+++ doc/en/release-notes/bzr-2.6.txt 2012-03-21 13:34:24 +0000
@@ -26,6 +26,9 @@
26.. Improvements to existing commands, especially improved performance 26.. Improvements to existing commands, especially improved performance
27 or memory usage, or better results.27 or memory usage, or better results.
2828
29* Colocated branches can now be addressed using the 'co:NAME' rather than
30 the more complex 'file://.,branch=NAME'. (Jelmer Vernooij, #833665)
31
29Bug Fixes32Bug Fixes
30*********33*********
3134