1
# Copyright (C) 2006, 2007 Canonical Ltd
1
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
605
605
class TestBranchControlGetBranchConf(tests.TestCaseWithMemoryTransport):
606
"""Test branch.control_files api munging...
608
We special case RemoteBranch.control_files.get('branch.conf') to
609
call a specific API so that RemoteBranch's can intercept configuration
610
file reading, allowing them to signal to the client about things like
611
'email is configured for commits'.
606
"""Getting the branch configuration should use an abstract method not vfs.
614
609
def test_get_branch_conf(self):
610
raise tests.KnownFailure('branch.conf is not retrieved by get_config_file')
611
# We should see that branch.get_config() does a single rpc to get the
612
# remote configuration file, abstracting away where that is stored on
613
# the server. However at the moment it always falls back to using the
614
# vfs, and this would need some changes in config.py.
615
616
# in an empty branch we decode the response properly
616
client = FakeClient([(('ok', ), 'config file body')], self.get_url())
617
client = FakeClient([(('ok', ), '# config file body')], self.get_url())
617
618
# we need to make a real branch because the remote_branch.control_files
618
619
# will trigger _ensure_real.
619
620
branch = self.make_branch('quack')
621
622
# we do not want bzrdir to make any remote calls
622
623
bzrdir = RemoteBzrDir(transport, _client=False)
623
624
branch = RemoteBranch(bzrdir, None, _client=client)
624
result = branch.control_files.get('branch.conf')
625
config = branch.get_config()
625
626
self.assertEqual(
626
627
[('call_expecting_body', 'Branch.get_config_file', ('quack/',))],
628
self.assertEqual('config file body', result.read())
631
631
class TestBranchLockWrite(tests.TestCase):
829
829
transport_path = 'quack'
830
830
repo, client = self.setup_fake_client_and_repository(
831
831
responses, transport_path)
832
self.assertTrue(client._medium._remote_is_at_least_1_2)
832
833
rev_id = 'revision-id'
833
834
expected_deprecations = [
834
835
'bzrlib.remote.RemoteRepository.get_revision_graph was deprecated '
842
843
('call_expecting_body', 'Repository.get_revision_graph',
843
844
('quack/', ''))],
846
# The medium is now marked as being connected to an older server
847
self.assertFalse(client._medium._remote_is_at_least_1_2)
849
def test_get_parent_map_fallback_parentless_node(self):
850
"""get_parent_map falls back to get_revision_graph on old servers. The
851
results from get_revision_graph are tweaked to match the get_parent_map
854
Specifically, a {key: ()} result from get_revision_graph means "no
855
parents" for that key, which in get_parent_map results should be
856
represented as {key: ('null:',)}.
858
This is the test for https://bugs.launchpad.net/bzr/+bug/214894
860
rev_id = 'revision-id'
861
responses = [(('ok',), rev_id)]
862
transport_path = 'quack'
863
repo, client = self.setup_fake_client_and_repository(
864
responses, transport_path)
865
client._medium._remote_is_at_least_1_2 = False
866
expected_deprecations = [
867
'bzrlib.remote.RemoteRepository.get_revision_graph was deprecated '
869
parents = self.callDeprecated(
870
expected_deprecations, repo.get_parent_map, [rev_id])
872
[('call_expecting_body', 'Repository.get_revision_graph',
875
self.assertEqual({rev_id: ('null:',)}, parents)
846
877
def test_get_parent_map_unexpected_response(self):