Merge lp:~jelmer/brz/reference-absolute into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/reference-absolute
Merge into: lp:brz
Diff against target: 94 lines (+26/-14)
5 files modified
breezy/builtins.py (+6/-6)
breezy/bzr/branch.py (+6/-6)
breezy/symbol_versioning.py (+1/-1)
breezy/tests/blackbox/test_switch.py (+1/-1)
breezy/tests/test_bzrdir.py (+12/-0)
To merge this branch: bzr merge lp:~jelmer/brz/reference-absolute
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+361390@code.launchpad.net

Commit message

Use absolute URLs in branch reference locations.

Description of the change

Use absolute URLs in branch reference locations.

This fixes backward compatibility with bzr.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thank you very much! Great to have the test too.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/builtins.py'
--- breezy/builtins.py 2019-01-01 23:40:59 +0000
+++ breezy/builtins.py 2019-01-04 21:32:20 +0000
@@ -206,13 +206,13 @@
206 try:206 try:
207 reference = control_dir.get_branch_reference()207 reference = control_dir.get_branch_reference()
208 except errors.NotBranchError:208 except errors.NotBranchError:
209 # There is no active branch, just return the colocated branches.209 reference = None
210 for name, branch in viewitems(control_dir.get_branches()):
211 yield name, branch
212 return
213 if reference is not None:210 if reference is not None:
214 ref_branch = Branch.open(211 try:
215 reference, possible_transports=possible_transports)212 ref_branch = Branch.open(
213 reference, possible_transports=possible_transports)
214 except errors.NotBranchError:
215 ref_branch = None
216 else:216 else:
217 ref_branch = None217 ref_branch = None
218 if ref_branch is None or ref_branch.name:218 if ref_branch is None or ref_branch.name:
219219
=== modified file 'breezy/bzr/branch.py'
--- breezy/bzr/branch.py 2018-11-30 12:39:04 +0000
+++ breezy/bzr/branch.py 2019-01-04 21:32:20 +0000
@@ -977,12 +977,12 @@
977977
978 def _write_reference(self, a_controldir, transport, to_branch):978 def _write_reference(self, a_controldir, transport, to_branch):
979 to_url = to_branch.user_url979 to_url = to_branch.user_url
980 if a_controldir.control_url == to_branch.controldir.control_url:980 # Ideally, we'd write a relative path here for the benefit of colocated
981 # Write relative paths for colocated branches, but absolute981 # branches - so that moving a control directory doesn't break
982 # paths for everything else. This is for the benefit982 # any references to colocated branches. Unfortunately, bzr
983 # of older bzr versions that don't support relative paths.983 # does not support relative URLs. See pad.lv/1803845 -- jelmer
984 to_url = urlutils.relative_url(984 # to_url = urlutils.relative_url(
985 a_controldir.user_url, to_branch.user_url)985 # a_controldir.user_url, to_branch.user_url)
986 transport.put_bytes('location', to_url.encode('utf-8'))986 transport.put_bytes('location', to_url.encode('utf-8'))
987987
988 def set_reference(self, a_controldir, name, to_branch):988 def set_reference(self, a_controldir, name, to_branch):
989989
=== modified file 'breezy/symbol_versioning.py'
--- breezy/symbol_versioning.py 2018-11-29 19:43:19 +0000
+++ breezy/symbol_versioning.py 2019-01-04 21:32:20 +0000
@@ -319,7 +319,7 @@
319 if filter:319 if filter:
320 try:320 try:
321 warnings.filters.remove(filter)321 warnings.filters.remove(filter)
322 except IndexError:322 except (ValueError, IndexError):
323 pass323 pass
324 return cleanup324 return cleanup
325325
326326
=== modified file 'breezy/tests/blackbox/test_switch.py'
--- breezy/tests/blackbox/test_switch.py 2018-12-21 18:57:26 +0000
+++ breezy/tests/blackbox/test_switch.py 2019-01-04 21:32:20 +0000
@@ -576,7 +576,7 @@
576 $ mv mywork mywork1576 $ mv mywork mywork1
577 $ cd mywork1577 $ cd mywork1
578 $ brz branches578 $ brz branches
579 * br1579 br1
580 ''', null_output_matches_anything=True)580 ''', null_output_matches_anything=True)
581581
582 def test_switch_to_new_branch_on_old_rev(self):582 def test_switch_to_new_branch_on_old_rev(self):
583583
=== modified file 'breezy/tests/test_bzrdir.py'
--- breezy/tests/test_bzrdir.py 2018-11-17 17:37:42 +0000
+++ breezy/tests/test_bzrdir.py 2019-01-04 21:32:20 +0000
@@ -1477,6 +1477,18 @@
1477 errors.AlreadyBranchError, tree.controldir.create_branch,1477 errors.AlreadyBranchError, tree.controldir.create_branch,
1478 name='foo')1478 name='foo')
14791479
1480 def test_supports_relative_reference(self):
1481 tree = self.make_branch_and_tree('.', format='development-colo')
1482 target1 = tree.controldir.create_branch(name='target1')
1483 target2 = tree.controldir.create_branch(name='target2')
1484 source = tree.controldir.set_branch_reference(target1, name='source')
1485 self.assertEqual(
1486 target1.user_url, tree.controldir.open_branch('source').user_url)
1487 source.controldir.get_branch_transport(None, 'source').put_bytes(
1488 'location', b'file:,branch=target2')
1489 self.assertEqual(
1490 target2.user_url, tree.controldir.open_branch('source').user_url)
1491
14801492
1481class SampleBzrFormat(bzrdir.BzrFormat):1493class SampleBzrFormat(bzrdir.BzrFormat):
14821494

Subscribers

People subscribed via source and target branches