Merge lp:~jelmer/brz/branch-reference-remote 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/branch-reference-remote
Merge into: lp:brz
Diff against target: 508 lines (+163/-64)
15 files modified
breezy/branch.py (+7/-3)
breezy/bzr/branch.py (+15/-25)
breezy/bzr/fullhistory.py (+2/-0)
breezy/bzr/remote.py (+50/-15)
breezy/bzr/smart/branch.py (+14/-0)
breezy/bzr/smart/request.py (+3/-0)
breezy/git/branch.py (+2/-0)
breezy/plugins/weave_fmt/branch.py (+2/-0)
breezy/tests/blackbox/test_branch.py (+8/-7)
breezy/tests/blackbox/test_checkout.py (+1/-1)
breezy/tests/blackbox/test_pull.py (+1/-1)
breezy/tests/per_workingtree/test_workingtree.py (+20/-12)
breezy/tests/test_remote.py (+20/-0)
breezy/tests/test_smart.py (+15/-0)
doc/en/release-notes/brz-3.1.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/brz/branch-reference-remote
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+377806@code.launchpad.net

Commit message

Support fetching / pushing reference information to remote branches.

Description of the change

Support fetching / pushing reference information to remote branches.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/branch.py'
--- breezy/branch.py 2020-01-19 03:22:04 +0000
+++ breezy/branch.py 2020-01-19 15:24:24 +0000
@@ -1271,7 +1271,7 @@
1271 revision_id=revision_id)1271 revision_id=revision_id)
12721272
1273 def update_references(self, target):1273 def update_references(self, target):
1274 if not getattr(self._format, 'supports_reference_locations', False):1274 if not self._format.supports_reference_locations:
1275 return1275 return
1276 return InterBranch.get(self, target).update_references()1276 return InterBranch.get(self, target).update_references()
12771277
@@ -2391,8 +2391,12 @@
2391 new_base = self.target.base2391 new_base = self.target.base
2392 target_reference_dict = self.target._get_all_reference_info()2392 target_reference_dict = self.target._get_all_reference_info()
2393 for tree_path, (branch_location, file_id) in viewitems(reference_dict):2393 for tree_path, (branch_location, file_id) in viewitems(reference_dict):
2394 branch_location = urlutils.rebase_url(branch_location,2394 try:
2395 old_base, new_base)2395 branch_location = urlutils.rebase_url(branch_location,
2396 old_base, new_base)
2397 except urlutils.InvalidRebaseURLs:
2398 # Fall back to absolute URL
2399 branch_location = urlutils.join(old_base, branch_location)
2396 target_reference_dict.setdefault(2400 target_reference_dict.setdefault(
2397 tree_path, (branch_location, file_id))2401 tree_path, (branch_location, file_id))
2398 self.target._set_all_reference_info(target_reference_dict)2402 self.target._set_all_reference_info(target_reference_dict)
23992403
=== modified file 'breezy/bzr/branch.py'
--- breezy/bzr/branch.py 2020-01-19 03:22:04 +0000
+++ breezy/bzr/branch.py 2020-01-19 15:24:24 +0000
@@ -465,11 +465,20 @@
465 :return: A branch associated with the nested tree465 :return: A branch associated with the nested tree
466 """466 """
467 try:467 try:
468 return Branch.open_from_transport(468 branch_location = self.get_reference_info(file_id)[0]
469 self.controldir.root_transport.clone(path),469 except errors.UnsupportedOperation:
470 possible_transports=possible_transports)470 branch_location = None
471 except errors.NotBranchError:471 if branch_location is None:
472 return None472 try:
473 return Branch.open_from_transport(
474 self.controldir.root_transport.clone(path),
475 possible_transports=possible_transports)
476 except errors.NotBranchError:
477 return None
478 return Branch.open(
479 urlutils.join(
480 urlutils.strip_segment_parameters(self.user_url), branch_location),
481 possible_transports=possible_transports)
473482
474483
475class BzrBranch8(BzrBranch):484class BzrBranch8(BzrBranch):
@@ -565,7 +574,7 @@
565 with self._transport.get('references') as rio_file:574 with self._transport.get('references') as rio_file:
566 stanzas = rio.read_stanzas(rio_file)575 stanzas = rio.read_stanzas(rio_file)
567 info_dict = {576 info_dict = {
568 s['file_id'].encode('ascii'): (577 s['file_id'].encode('utf-8'): (
569 s['branch_location'],578 s['branch_location'],
570 s['tree_path'] if 'tree_path' in s else None)579 s['tree_path'] if 'tree_path' in s else None)
571 for s in stanzas}580 for s in stanzas}
@@ -595,25 +604,6 @@
595 """604 """
596 return self._get_all_reference_info().get(file_id, (None, None))605 return self._get_all_reference_info().get(file_id, (None, None))
597606
598 def reference_parent(self, file_id, path, possible_transports=None):
599 """Return the parent branch for a tree-reference.
600
601 :param path: The path of the nested tree in the tree
602 :return: A branch associated with the nested tree
603 """
604 branch_location = self.get_reference_info(file_id)[0]
605 if branch_location is None:
606 try:
607 return Branch.open_from_transport(
608 self.controldir.root_transport.clone(path),
609 possible_transports=possible_transports)
610 except errors.NotBranchError:
611 return None
612 else:
613 branch_location = urlutils.join(self.user_url, branch_location)
614 return Branch.open(
615 branch_location, possible_transports=possible_transports)
616
617 def set_push_location(self, location):607 def set_push_location(self, location):
618 """See Branch.set_push_location."""608 """See Branch.set_push_location."""
619 self._set_config_location('push_location', location)609 self._set_config_location('push_location', location)
620610
=== modified file 'breezy/bzr/fullhistory.py'
--- breezy/bzr/fullhistory.py 2018-11-11 04:08:32 +0000
+++ breezy/bzr/fullhistory.py 2020-01-19 15:24:24 +0000
@@ -173,3 +173,5 @@
173173
174 def supports_tags(self):174 def supports_tags(self):
175 return False175 return False
176
177 supports_reference_locations = False
176178
=== modified file 'breezy/bzr/remote.py'
--- breezy/bzr/remote.py 2020-01-18 22:02:05 +0000
+++ breezy/bzr/remote.py 2020-01-19 15:24:24 +0000
@@ -3397,6 +3397,11 @@
3397 self._ensure_real()3397 self._ensure_real()
3398 return self._custom_format.supports_set_append_revisions_only()3398 return self._custom_format.supports_set_append_revisions_only()
33993399
3400 @property
3401 def supports_reference_locations(self):
3402 self._ensure_real()
3403 return self._custom_format.supports_reference_locations
3404
3400 def stores_revno(self):3405 def stores_revno(self):
3401 return True3406 return True
34023407
@@ -3415,8 +3420,6 @@
3415 return True3420 return True
3416 return False3421 return False
34173422
3418 supports_reference_locations = False
3419
34203423
3421class RemoteBranchStore(_mod_config.IniFileStore):3424class RemoteBranchStore(_mod_config.IniFileStore):
3422 """Branch store which attempts to use HPSS calls to retrieve branch store.3425 """Branch store which attempts to use HPSS calls to retrieve branch store.
@@ -4179,28 +4182,60 @@
4179 reconciler = BranchReconciler(self, thorough=thorough)4182 reconciler = BranchReconciler(self, thorough=thorough)
4180 return reconciler.reconcile()4183 return reconciler.reconcile()
41814184
4182 def set_reference_info(self, tree_path, branch_location, file_id=None):4185 def get_reference_info(self, file_id):
4183 raise errors.UnsupportedOperation(self.set_reference_info, self)4186 """Get the tree_path and branch_location for a tree reference."""
41844187 if not self._format.supports_reference_locations:
4185 def get_reference_info(self, tree_path):4188 raise errors.UnsupportedOperation(self.get_reference_info, self)
4186 raise errors.UnsupportedOperation(self.get_reference_info, self)4189 return self._get_all_reference_info().get(file_id, (None, None))
4190
4191 def set_reference_info(self, file_id, branch_location, tree_path=None):
4192 """Set the branch location to use for a tree reference."""
4193 if not self._format.supports_reference_locations:
4194 raise errors.UnsupportedOperation(self.set_reference_info, self)
4195 self._ensure_real()
4196 self._real_branch.set_reference_info(
4197 file_id, branch_location, tree_path)
4198
4199 def _set_all_reference_info(self, reference_info):
4200 if not self._format.supports_reference_locations:
4201 raise errors.UnsupportedOperation(self.set_reference_info, self)
4202 self._ensure_real()
4203 self._real_branch._set_all_reference_info(reference_info)
41874204
4188 def _get_all_reference_info(self):4205 def _get_all_reference_info(self):
4189 self._ensure_real()4206 if not self._format.supports_reference_locations:
4190 return self._real_branch._get_all_reference_info()4207 return {}
4208 try:
4209 response, handler = self._call_expecting_body(
4210 b'Branch.get_all_reference_info', self._remote_path())
4211 except errors.UnknownSmartMethod:
4212 self._ensure_real()
4213 return self._real_branch._get_all_reference_info()
4214 if len(response) and response[0] != b'ok':
4215 raise errors.UnexpectedSmartServerResponse(response)
4216 ret = {}
4217 for (f, u, p) in bencode.bdecode(handler.read_body_bytes()):
4218 ret[f] = (u.decode('utf-8'), p.decode('utf-8') if p else None)
4219 return ret
41914220
4192 def reference_parent(self, path, possible_transports=None):4221 def reference_parent(self, file_id, path, possible_transports=None):
4193 """Return the parent branch for a tree-reference.4222 """Return the parent branch for a tree-reference.
41944223
4195 :param path: The path of the nested tree in the tree4224 :param path: The path of the nested tree in the tree
4196 :return: A branch associated with the nested tree4225 :return: A branch associated with the nested tree
4197 """4226 """
4198 branch_location = self.get_reference_info(path)[0]4227 branch_location = self.get_reference_info(file_id)[0]
4199 if branch_location is None:4228 if branch_location is None:
4200 return BzrBranch.reference_parent(self, path, possible_transports)4229 try:
4201 branch_location = urlutils.join(self.user_url, branch_location)4230 return branch.Branch.open_from_transport(
4202 return Branch.open(branch_location,4231 self.controldir.root_transport.clone(path),
4203 possible_transports=possible_transports)4232 possible_transports=possible_transports)
4233 except errors.NotBranchError:
4234 return None
4235 return branch.Branch.open(
4236 urlutils.join(
4237 urlutils.strip_segment_parameters(self.user_url), branch_location),
4238 possible_transports=possible_transports)
42044239
42054240
4206class RemoteConfig(object):4241class RemoteConfig(object):
42074242
=== modified file 'breezy/bzr/smart/branch.py'
--- breezy/bzr/smart/branch.py 2019-03-06 21:27:22 +0000
+++ breezy/bzr/smart/branch.py 2020-01-19 15:24:24 +0000
@@ -439,3 +439,17 @@
439 return SuccessfulSmartServerResponse((b'yes',))439 return SuccessfulSmartServerResponse((b'yes',))
440 else:440 else:
441 return SuccessfulSmartServerResponse((b'no',))441 return SuccessfulSmartServerResponse((b'no',))
442
443
444class SmartServerBranchRequestGetAllReferenceInfo(SmartServerBranchRequest):
445 """Get the reference information.
446
447 New in 3.1.
448 """
449
450 def do_with_branch(self, branch):
451 all_reference_info = branch._get_all_reference_info()
452 content = bencode.bencode([
453 (key, value[0].encode('utf-8'), value[1].encode('utf-8') if value[1] else b'')
454 for (key, value) in all_reference_info.items()])
455 return SuccessfulSmartServerResponse((b'ok', ), content)
442456
=== modified file 'breezy/bzr/smart/request.py'
--- breezy/bzr/smart/request.py 2019-06-30 10:50:40 +0000
+++ breezy/bzr/smart/request.py 2020-01-19 15:24:24 +0000
@@ -609,6 +609,9 @@
609 b'Branch.revision_id_to_revno', 'breezy.bzr.smart.branch',609 b'Branch.revision_id_to_revno', 'breezy.bzr.smart.branch',
610 'SmartServerBranchRequestRevisionIdToRevno', info='read')610 'SmartServerBranchRequestRevisionIdToRevno', info='read')
611request_handlers.register_lazy(611request_handlers.register_lazy(
612 b'Branch.get_all_reference_info', 'breezy.bzr.smart.branch',
613 'SmartServerBranchRequestGetAllReferenceInfo', info='read')
614request_handlers.register_lazy(
612 b'BzrDir.checkout_metadir', 'breezy.bzr.smart.bzrdir',615 b'BzrDir.checkout_metadir', 'breezy.bzr.smart.bzrdir',
613 'SmartServerBzrDirRequestCheckoutMetaDir', info='read')616 'SmartServerBzrDirRequestCheckoutMetaDir', info='read')
614request_handlers.register_lazy(617request_handlers.register_lazy(
615618
=== modified file 'breezy/git/branch.py'
--- breezy/git/branch.py 2020-01-18 16:15:37 +0000
+++ breezy/git/branch.py 2020-01-19 15:24:24 +0000
@@ -348,6 +348,8 @@
348 """True if this branch format store revision numbers."""348 """True if this branch format store revision numbers."""
349 return False349 return False
350350
351 supports_reference_locations = False
352
351353
352class LocalGitBranchFormat(GitBranchFormat):354class LocalGitBranchFormat(GitBranchFormat):
353355
354356
=== modified file 'breezy/plugins/weave_fmt/branch.py'
--- breezy/plugins/weave_fmt/branch.py 2018-11-11 04:08:32 +0000
+++ breezy/plugins/weave_fmt/branch.py 2020-01-19 15:24:24 +0000
@@ -215,3 +215,5 @@
215215
216 def supports_leaving_lock(self):216 def supports_leaving_lock(self):
217 return False217 return False
218
219 supports_reference_locations = False
218220
=== modified file 'breezy/tests/blackbox/test_branch.py'
--- breezy/tests/blackbox/test_branch.py 2020-01-19 03:22:04 +0000
+++ breezy/tests/blackbox/test_branch.py 2020-01-19 15:24:24 +0000
@@ -557,9 +557,10 @@
557 # become necessary for this use case. Please do not adjust this number557 # become necessary for this use case. Please do not adjust this number
558 # upwards without agreement from bzr's network support maintainers.558 # upwards without agreement from bzr's network support maintainers.
559 self.assertLength(2, self.hpss_connections)559 self.assertLength(2, self.hpss_connections)
560 self.assertLength(33, self.hpss_calls)560 self.assertLength(34, self.hpss_calls)
561 self.expectFailure("branching to the same branch requires VFS access",561 self.expectFailure(
562 self.assertThat, self.hpss_calls, ContainsNoVfsCalls)562 "branching to the same branch requires VFS access",
563 self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
563564
564 def test_branch_from_trivial_branch_streaming_acceptance(self):565 def test_branch_from_trivial_branch_streaming_acceptance(self):
565 self.setup_smart_server_with_call_log()566 self.setup_smart_server_with_call_log()
@@ -575,7 +576,7 @@
575 # become necessary for this use case. Please do not adjust this number576 # become necessary for this use case. Please do not adjust this number
576 # upwards without agreement from bzr's network support maintainers.577 # upwards without agreement from bzr's network support maintainers.
577 self.assertThat(self.hpss_calls, ContainsNoVfsCalls)578 self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
578 self.assertLength(10, self.hpss_calls)579 self.assertLength(11, self.hpss_calls)
579 self.assertLength(1, self.hpss_connections)580 self.assertLength(1, self.hpss_connections)
580581
581 def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):582 def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
@@ -597,7 +598,7 @@
597 # being too low. If rpc_count increases, more network roundtrips have598 # being too low. If rpc_count increases, more network roundtrips have
598 # become necessary for this use case. Please do not adjust this number599 # become necessary for this use case. Please do not adjust this number
599 # upwards without agreement from bzr's network support maintainers.600 # upwards without agreement from bzr's network support maintainers.
600 self.assertLength(15, self.hpss_calls)601 self.assertLength(16, self.hpss_calls)
601 self.assertLength(1, self.hpss_connections)602 self.assertLength(1, self.hpss_connections)
602 self.assertThat(self.hpss_calls, ContainsNoVfsCalls)603 self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
603604
@@ -617,7 +618,7 @@
617 # being too low. If rpc_count increases, more network roundtrips have618 # being too low. If rpc_count increases, more network roundtrips have
618 # become necessary for this use case. Please do not adjust this number619 # become necessary for this use case. Please do not adjust this number
619 # upwards without agreement from bzr's network support maintainers.620 # upwards without agreement from bzr's network support maintainers.
620 self.assertLength(10, self.hpss_calls)621 self.assertLength(11, self.hpss_calls)
621 self.assertThat(self.hpss_calls, ContainsNoVfsCalls)622 self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
622 self.assertLength(1, self.hpss_connections)623 self.assertLength(1, self.hpss_connections)
623624
@@ -659,7 +660,7 @@
659 # become necessary for this use case. Please do not adjust this number660 # become necessary for this use case. Please do not adjust this number
660 # upwards without agreement from bzr's network support maintainers.661 # upwards without agreement from bzr's network support maintainers.
661 self.assertThat(self.hpss_calls, ContainsNoVfsCalls)662 self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
662 self.assertLength(11, self.hpss_calls)663 self.assertLength(12, self.hpss_calls)
663 self.assertLength(1, self.hpss_connections)664 self.assertLength(1, self.hpss_connections)
664665
665666
666667
=== modified file 'breezy/tests/blackbox/test_checkout.py'
--- breezy/tests/blackbox/test_checkout.py 2018-11-11 04:08:32 +0000
+++ breezy/tests/blackbox/test_checkout.py 2020-01-19 15:24:24 +0000
@@ -211,7 +211,7 @@
211 # being too low. If rpc_count increases, more network roundtrips have211 # being too low. If rpc_count increases, more network roundtrips have
212 # become necessary for this use case. Please do not adjust this number212 # become necessary for this use case. Please do not adjust this number
213 # upwards without agreement from bzr's network support maintainers.213 # upwards without agreement from bzr's network support maintainers.
214 self.assertLength(10, self.hpss_calls)214 self.assertLength(11, self.hpss_calls)
215 self.assertLength(1, self.hpss_connections)215 self.assertLength(1, self.hpss_connections)
216 self.assertThat(self.hpss_calls, ContainsNoVfsCalls)216 self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
217217
218218
=== modified file 'breezy/tests/blackbox/test_pull.py'
--- breezy/tests/blackbox/test_pull.py 2019-02-09 02:59:15 +0000
+++ breezy/tests/blackbox/test_pull.py 2020-01-19 15:24:24 +0000
@@ -413,7 +413,7 @@
413 # being too low. If rpc_count increases, more network roundtrips have413 # being too low. If rpc_count increases, more network roundtrips have
414 # become necessary for this use case. Please do not adjust this number414 # become necessary for this use case. Please do not adjust this number
415 # upwards without agreement from bzr's network support maintainers.415 # upwards without agreement from bzr's network support maintainers.
416 self.assertLength(19, self.hpss_calls)416 self.assertLength(20, self.hpss_calls)
417 self.assertLength(1, self.hpss_connections)417 self.assertLength(1, self.hpss_connections)
418 remote = branch.Branch.open('stacked')418 remote = branch.Branch.open('stacked')
419 self.assertEndsWith(remote.get_stacked_on_url(), '/parent')419 self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
420420
=== modified file 'breezy/tests/per_workingtree/test_workingtree.py'
--- breezy/tests/per_workingtree/test_workingtree.py 2020-01-19 03:22:04 +0000
+++ breezy/tests/per_workingtree/test_workingtree.py 2020-01-19 15:24:24 +0000
@@ -1385,8 +1385,8 @@
1385 tree = WorkingTree.open('branch')1385 tree = WorkingTree.open('branch')
1386 branch_location = tree.get_reference_info('path/to/file')1386 branch_location = tree.get_reference_info('path/to/file')
1387 self.assertEqual(1387 self.assertEqual(
1388 urlutils.local_path_to_url('branch/path/to/location'),1388 urlutils.join(urlutils.strip_segment_parameters(tree.branch.user_url), 'path/to/location'),
1389 urlutils.join(tree.branch.user_url, branch_location))1389 urlutils.join(urlutils.strip_segment_parameters(tree.branch.user_url), branch_location))
13901390
1391 def test_set_null_reference_info(self):1391 def test_set_null_reference_info(self):
1392 tree = self.make_branch_and_tree('branch')1392 tree = self.make_branch_and_tree('branch')
@@ -1443,7 +1443,8 @@
1443 tree = self.make_tree_with_reference('branch', '../reference')1443 tree = self.make_tree_with_reference('branch', '../reference')
1444 new_tree = tree.branch.controldir.sprout('new-branch').open_workingtree()1444 new_tree = tree.branch.controldir.sprout('new-branch').open_workingtree()
1445 self.assertEqual(1445 self.assertEqual(
1446 urlutils.local_path_to_url('reference'),1446 urlutils.join(urlutils.strip_segment_parameters(tree.branch.user_url),
1447 '../reference'),
1447 urlutils.join(urlutils.strip_segment_parameters(new_tree.branch.user_url),1448 urlutils.join(urlutils.strip_segment_parameters(new_tree.branch.user_url),
1448 new_tree.get_reference_info('path/to/file')))1449 new_tree.get_reference_info('path/to/file')))
14491450
@@ -1451,7 +1452,7 @@
1451 tree = self.make_tree_with_reference('branch', '../reference')1452 tree = self.make_tree_with_reference('branch', '../reference')
1452 new_tree = tree.controldir.clone('new-branch').open_workingtree()1453 new_tree = tree.controldir.clone('new-branch').open_workingtree()
1453 self.assertEqual(1454 self.assertEqual(
1454 urlutils.local_path_to_url('reference'),1455 urlutils.join(urlutils.strip_segment_parameters(tree.branch.user_url), '../reference'),
1455 urlutils.join(urlutils.strip_segment_parameters(new_tree.branch.user_url),1456 urlutils.join(urlutils.strip_segment_parameters(new_tree.branch.user_url),
1456 new_tree.get_reference_info('path/to/file')))1457 new_tree.get_reference_info('path/to/file')))
14571458
@@ -1460,7 +1461,8 @@
1460 new_tree = tree.controldir.sprout(1461 new_tree = tree.controldir.sprout(
1461 'branch/new-branch').open_workingtree()1462 'branch/new-branch').open_workingtree()
1462 self.assertEqual(1463 self.assertEqual(
1463 urlutils.local_path_to_url('branch/reference'),1464 urlutils.join(urlutils.strip_segment_parameters(tree.branch.user_url),
1465 'reference'),
1464 urlutils.join(urlutils.strip_segment_parameters(new_tree.branch.user_url),1466 urlutils.join(urlutils.strip_segment_parameters(new_tree.branch.user_url),
1465 new_tree.get_reference_info('path/to/file')))1467 new_tree.get_reference_info('path/to/file')))
14661468
@@ -1470,7 +1472,9 @@
1470 'new_branch', 'reference2')1472 'new_branch', 'reference2')
1471 new_tree.branch.update_references(tree.branch)1473 new_tree.branch.update_references(tree.branch)
1472 self.assertEqual(1474 self.assertEqual(
1473 urlutils.local_path_to_url('branch/reference'),1475 urlutils.join(
1476 urlutils.strip_segment_parameters(tree.branch.user_url),
1477 'reference'),
1474 urlutils.join(1478 urlutils.join(
1475 urlutils.strip_segment_parameters(tree.branch.user_url),1479 urlutils.strip_segment_parameters(tree.branch.user_url),
1476 tree.get_reference_info('path/to/file')))1480 tree.get_reference_info('path/to/file')))
@@ -1481,7 +1485,9 @@
1481 'new_branch', 'reference2')1485 'new_branch', 'reference2')
1482 new_tree.branch.update_references(tree.branch)1486 new_tree.branch.update_references(tree.branch)
1483 self.assertEqual(1487 self.assertEqual(
1484 urlutils.local_path_to_url('branch/reference'),1488 urlutils.join(
1489 urlutils.strip_segment_parameters(tree.branch.user_url),
1490 'reference'),
1485 urlutils.join(1491 urlutils.join(
1486 urlutils.strip_segment_parameters(tree.branch.user_url),1492 urlutils.strip_segment_parameters(tree.branch.user_url),
1487 tree.get_reference_info('path/to/file')))1493 tree.get_reference_info('path/to/file')))
@@ -1495,7 +1501,9 @@
1495 new_tree.set_reference_info('foo', '../foo')1501 new_tree.set_reference_info('foo', '../foo')
1496 new_tree.branch.update_references(tree.branch)1502 new_tree.branch.update_references(tree.branch)
1497 self.assertEqual(1503 self.assertEqual(
1498 urlutils.local_path_to_url('branch/reference'),1504 urlutils.join(
1505 urlutils.strip_segment_parameters(tree.branch.user_url),
1506 'reference'),
1499 urlutils.join(1507 urlutils.join(
1500 urlutils.strip_segment_parameters(tree.branch.user_url),1508 urlutils.strip_segment_parameters(tree.branch.user_url),
1501 tree.get_reference_info('path/to/file')))1509 tree.get_reference_info('path/to/file')))
@@ -1510,7 +1518,7 @@
1510 new_tree.commit('set reference')1518 new_tree.commit('set reference')
1511 tree.pull(new_tree.branch)1519 tree.pull(new_tree.branch)
1512 self.assertEqual(1520 self.assertEqual(
1513 urlutils.local_path_to_url('branch/foo'),1521 urlutils.join(urlutils.strip_segment_parameters(new_tree.branch.user_url), '../foo'),
1514 urlutils.join(tree.branch.user_url, tree.get_reference_info('foo')))1522 urlutils.join(tree.branch.user_url, tree.get_reference_info('foo')))
15151523
1516 def test_push_updates_references(self):1524 def test_push_updates_references(self):
@@ -1524,8 +1532,8 @@
1524 tree.pull(new_tree.branch)1532 tree.pull(new_tree.branch)
1525 tree.update()1533 tree.update()
1526 self.assertEqual(1534 self.assertEqual(
1527 urlutils.local_path_to_url('branch/foo'),1535 urlutils.join(urlutils.strip_segment_parameters(new_tree.branch.user_url), '../foo'),
1528 urlutils.join(tree.branch.user_url, tree.get_reference_info('foo')))1536 urlutils.join(urlutils.strip_segment_parameters(tree.branch.user_url), tree.get_reference_info('foo')))
15291537
1530 def test_merge_updates_references(self):1538 def test_merge_updates_references(self):
1531 orig_tree = self.make_tree_with_reference('branch', 'reference')1539 orig_tree = self.make_tree_with_reference('branch', 'reference')
@@ -1542,5 +1550,5 @@
1542 merger.merge_type = merge.Merge3Merger1550 merger.merge_type = merge.Merge3Merger
1543 merger.do_merge()1551 merger.do_merge()
1544 self.assertEqual(1552 self.assertEqual(
1545 urlutils.local_path_to_url('branch/reference'),1553 urlutils.join(urlutils.strip_segment_parameters(orig_tree.branch.user_url), 'reference'),
1546 urlutils.join(urlutils.strip_segment_parameters(tree.branch.user_url), tree.get_reference_info('path/to/file')))1554 urlutils.join(urlutils.strip_segment_parameters(tree.branch.user_url), tree.get_reference_info('path/to/file')))
15471555
=== modified file 'breezy/tests/test_remote.py'
--- breezy/tests/test_remote.py 2019-11-06 01:31:41 +0000
+++ breezy/tests/test_remote.py 2020-01-19 15:24:24 +0000
@@ -4529,3 +4529,23 @@
4529 (b'baserevid', b'line 1\n'),4529 (b'baserevid', b'line 1\n'),
4530 (b'somerevid', b'line2\n')],4530 (b'somerevid', b'line2\n')],
4531 list(tree.annotate_iter('filename')))4531 list(tree.annotate_iter('filename')))
4532
4533
4534class TestBranchGetAllReferenceInfo(RemoteBranchTestCase):
4535
4536 def test_get_all_reference_info(self):
4537 transport = MemoryTransport()
4538 client = FakeClient(transport.base)
4539 client.add_expected_call(
4540 b'Branch.get_stacked_on_url', (b'quack/',),
4541 b'error', (b'NotStacked',))
4542 client.add_expected_call(
4543 b'Branch.get_all_reference_info', (b'quack/',),
4544 b'success', (b'ok',), bencode.bencode([
4545 (b'file-id', b'https://www.example.com/', b'')]))
4546 transport.mkdir('quack')
4547 transport = transport.clone('quack')
4548 branch = self.make_remote_branch(transport, client)
4549 result = branch._get_all_reference_info()
4550 self.assertFinished(client)
4551 self.assertEqual({b'file-id': ('https://www.example.com/', None)}, result)
45324552
=== modified file 'breezy/tests/test_smart.py'
--- breezy/tests/test_smart.py 2019-12-23 03:04:00 +0000
+++ breezy/tests/test_smart.py 2020-01-19 15:24:24 +0000
@@ -2819,3 +2819,18 @@
2819 self.assertEqual(2819 self.assertEqual(
2820 [[b'somerev', b'somecontents\n'], [b'somerev', b'morecontents\n']],2820 [[b'somerev', b'somecontents\n'], [b'somerev', b'morecontents\n']],
2821 bencode.bdecode(response.body))2821 bencode.bdecode(response.body))
2822
2823
2824class TestSmartServerBranchRequestGetAllReferenceInfo(TestLockedBranch):
2825
2826 def test_get_some(self):
2827 backing = self.get_transport()
2828 request = smart_branch.SmartServerBranchRequestGetAllReferenceInfo(backing)
2829 branch = self.make_branch('.')
2830 branch.set_reference_info('some/path', 'http://www.example.com/')
2831 response = request.execute(b'')
2832 self.assertTrue(response.is_successful())
2833 self.assertEqual(response.args, (b"ok", ))
2834 self.assertEqual(
2835 [[b'some/path', b'http://www.example.com/', b'']],
2836 bencode.bdecode(response.body))
28222837
=== modified file 'doc/en/release-notes/brz-3.1.txt'
--- doc/en/release-notes/brz-3.1.txt 2020-01-12 23:41:10 +0000
+++ doc/en/release-notes/brz-3.1.txt 2020-01-19 15:24:24 +0000
@@ -46,6 +46,9 @@
46 have installed and speeds up import time since psutil brings in46 have installed and speeds up import time since psutil brings in
47 various other modules. (Jelmer Vernooij)47 various other modules. (Jelmer Vernooij)
4848
49 * Information about tree references can now be updated on remote
50 branches. (Jelmer Vernooij)
51
49 * Warn the user when they attempt to use Breezy in a Subversion52 * Warn the user when they attempt to use Breezy in a Subversion
50 working copy. (Jelmer Vernooij)53 working copy. (Jelmer Vernooij)
5154

Subscribers

People subscribed via source and target branches