Merge lp:~jelmer/brz/resolve-location into lp:brz

Proposed by Jelmer Vernooij on 2019-02-24
Status: Merged
Approved by: Jelmer Vernooij on 2019-05-28
Approved revision: 7292
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/resolve-location
Merge into: lp:brz
Diff against target: 87 lines (+61/-0)
3 files modified
breezy/builtins.py (+18/-0)
breezy/tests/blackbox/__init__.py (+1/-0)
breezy/tests/blackbox/test_resolve_location.py (+42/-0)
To merge this branch: bzr merge lp:~jelmer/brz/resolve-location
Reviewer Review Type Date Requested Status
Martin Packman 2019-02-24 Approve on 2019-05-26
Review via email: mp+363581@code.launchpad.net

Commit message

Add a 'brz resolve-location' command.

Description of the change

Add a 'brz resolve-location' command.

This command is mostly useful for debugging issues of various kinds, and therefore hidden.

To post a comment you must log in.
Martin Packman (gz) wrote :

Make sense. Should perhaps go through `urlutils.unescape_for_display()` as well?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/builtins.py'
2--- breezy/builtins.py 2019-03-03 23:05:11 +0000
3+++ breezy/builtins.py 2019-05-26 22:29:00 +0000
4@@ -7018,6 +7018,24 @@
5 grep.versioned_grep(opts)
6
7
8+class cmd_resolve_location(Command):
9+ __doc__ = """Expand a location to a full URL.
10+
11+ :Examples:
12+ Look up a Launchpad URL.
13+
14+ brz resolve-location lp:brz
15+ """
16+ takes_args = ['location']
17+ hidden = True
18+
19+ def run(self, location):
20+ from .location import location_to_url
21+ url = location_to_url(location)
22+ display_url = urlutils.unescape_for_display(url, self.outf.encoding)
23+ self.outf.write('%s\n' % url)
24+
25+
26 def _register_lazy_builtins():
27 # register lazy builtins from other modules; called at startup and should
28 # be only called once.
29
30=== modified file 'breezy/tests/blackbox/__init__.py'
31--- breezy/tests/blackbox/__init__.py 2018-11-11 04:08:32 +0000
32+++ breezy/tests/blackbox/__init__.py 2019-05-26 22:29:00 +0000
33@@ -106,6 +106,7 @@
34 'test_remove_tree',
35 'test_repair_workingtree',
36 'test_resolve',
37+ 'test_resolve_location',
38 'test_revert',
39 'test_revno',
40 'test_revision_history',
41
42=== added file 'breezy/tests/blackbox/test_resolve_location.py'
43--- breezy/tests/blackbox/test_resolve_location.py 1970-01-01 00:00:00 +0000
44+++ breezy/tests/blackbox/test_resolve_location.py 2019-05-26 22:29:00 +0000
45@@ -0,0 +1,42 @@
46+# Copyright (C) 2019 Breezy Developers
47+#
48+# This program is free software; you can redistribute it and/or modify
49+# it under the terms of the GNU General Public License as published by
50+# the Free Software Foundation; either version 2 of the License, or
51+# (at your option) any later version.
52+#
53+# This program is distributed in the hope that it will be useful,
54+# but WITHOUT ANY WARRANTY; without even the implied warranty of
55+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
56+# GNU General Public License for more details.
57+#
58+# You should have received a copy of the GNU General Public License
59+# along with this program; if not, write to the Free Software
60+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
61+
62+
63+from breezy.tests import TestCaseWithTransport
64+
65+
66+class TestCatRevision(TestCaseWithTransport):
67+
68+ def test_already_url(self):
69+ wt = self.make_branch_and_tree('.')
70+
71+ out, err = self.run_bzr('resolve-location %s' % wt.branch.user_url)
72+ self.assertEqual(out, '%s\n' % wt.branch.user_url)
73+
74+ def test_parent_missing(self):
75+ wt = self.make_branch_and_tree('.')
76+
77+ out, err = self.run_bzr('resolve-location :parent', retcode=3)
78+ self.assertEqual(out, '')
79+ self.assertEqual(err, 'brz: ERROR: No parent location assigned.\n')
80+
81+ def test_parent(self):
82+ wt = self.make_branch_and_tree('.')
83+ wt.branch.set_parent('http://example.com/foo')
84+
85+ out, err = self.run_bzr('resolve-location :parent')
86+ self.assertEqual(out, 'http://example.com/foo\n')
87+ self.assertEqual(err, '')

Subscribers

People subscribed via source and target branches