Merge lp:~nmb/bzr/lp-open-containing into lp:bzr

Proposed by Neil Martinsen-Burrell
Status: Merged
Merged at revision: not available
Proposed branch: lp:~nmb/bzr/lp-open-containing
Merge into: lp:bzr
Diff against target: 55 lines (+18/-1)
3 files modified
NEWS (+4/-0)
bzrlib/plugins/launchpad/__init__.py (+1/-1)
bzrlib/plugins/launchpad/test_lp_open.py (+13/-0)
To merge this branch: bzr merge lp:~nmb/bzr/lp-open-containing
Reviewer Review Type Date Requested Status
John A Meinel Approve
Vincent Ladeuil Approve
Review via email: mp+15754@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Neil Martinsen-Burrell (nmb) wrote :

launchpad-open doesn't work when called from a subdirectory of a branch (for example when hacking in bzr.dev/bzrlib/plugins/launchpad, bzr lp-open raises "NotLaunchpadBranch") This fixes that by using open_containing instead of open. The included test fails without the change and passes with it.

Revision history for this message
Vincent Ladeuil (vila) wrote :

Excellent, one test, failing before, passing after. No brainer :)

I don't approve yet because I'm pretty sure there a bug for that, so if you can find it and update the NEWS entry, I'll be happy to approve. If not, I'll try to find it back myself but I thought you may have started from it and just forget to mention it.

review: Needs Information
Revision history for this message
Neil Martinsen-Burrell (nmb) wrote :

489102, updated in that branch

Revision history for this message
Vincent Ladeuil (vila) wrote :

Thank and again: well done !

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

+
45 + def test_launchpad_branch_subdirectory(self):
46 + # lp-open in a subdirectory of a registered branch should work
47 + wt = self.make_branch_and_tree('lp')
48 + wt.branch.set_push_location(
49 + 'bzr+ssh://bazaar.launchpad.net/~foo/bar/baz')
50 + self.build_tree(['lp/a/'])
51 + os.chdir('lp/a')
52 + self.assertEqual(
53 + ['Opening https://code.edge.launchpad.net/~foo/bar/baz in web '
54 + 'browser'],
55 + self.run_open('.'))

^- did you need 'os.chdir()' rather than 'self.run_open('lp/a')' ?

Anyway, approve regardless, and I'll merge, but I prefer to avoid chdir when possible. (As it is changing global state, and is something we try not to do withing bzrlib. We certainly have tests that do it, but we've moved some of that out into run_bzr(working_dir=...))

review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

Test fixed in a later submission because postponed test updates never occur otherwise :D

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2009-12-07 10:38:09 +0000
3+++ NEWS 2009-12-07 17:11:12 +0000
4@@ -89,6 +89,10 @@
5 passed to the external diff tool. This allows the file to be edited if the
6 diff tool provides for this. (Gary van der Merwe, #490738)
7
8+* The launchpad-open command can now be used from a subdirectory of a
9+ branch, not just from the root of the branch.
10+ (Neil Martinsen-Burrell, #489102)
11+
12
13 Improvements
14 ************
15
16=== modified file 'bzrlib/plugins/launchpad/__init__.py'
17--- bzrlib/plugins/launchpad/__init__.py 2009-10-30 14:44:52 +0000
18+++ bzrlib/plugins/launchpad/__init__.py 2009-12-07 17:11:12 +0000
19@@ -170,7 +170,7 @@
20 """Yield possible external locations for the branch at 'location'."""
21 yield location
22 try:
23- branch = _mod_branch.Branch.open(location)
24+ branch = _mod_branch.Branch.open_containing(location)[0]
25 except NotBranchError:
26 return
27 branch_url = branch.get_public_branch()
28
29=== modified file 'bzrlib/plugins/launchpad/test_lp_open.py'
30--- bzrlib/plugins/launchpad/test_lp_open.py 2009-03-23 14:59:43 +0000
31+++ bzrlib/plugins/launchpad/test_lp_open.py 2009-12-07 17:11:12 +0000
32@@ -17,6 +17,7 @@
33 """Tests for the launchpad-open command."""
34
35 from bzrlib.tests import TestCaseWithTransport
36+import os
37
38
39 class TestLaunchpadOpen(TestCaseWithTransport):
40@@ -87,3 +88,15 @@
41 ['Opening https://code.edge.launchpad.net/~foo/bar/baz in web '
42 'browser'],
43 self.run_open('bzr+ssh://bazaar.launchpad.net/~foo/bar/baz'))
44+
45+ def test_launchpad_branch_subdirectory(self):
46+ # lp-open in a subdirectory of a registered branch should work
47+ wt = self.make_branch_and_tree('lp')
48+ wt.branch.set_push_location(
49+ 'bzr+ssh://bazaar.launchpad.net/~foo/bar/baz')
50+ self.build_tree(['lp/a/'])
51+ os.chdir('lp/a')
52+ self.assertEqual(
53+ ['Opening https://code.edge.launchpad.net/~foo/bar/baz in web '
54+ 'browser'],
55+ self.run_open('.'))