1
# Copyright (C) 2006-2010 Canonical Ltd
1
# Copyright (C) 2006-2011 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
34
34
from bzrlib.tests import (
40
41
from bzrlib.transport import memory
43
def load_tests(standard_tests, module, loader):
44
"""Multiply tests for the push command."""
45
result = loader.suiteClass()
47
# one for each king of change
48
changes_tests, remaining_tests = tests.split_suite_by_condition(
49
standard_tests, tests.condition_isinstance((
50
TestPushStrictWithChanges,
54
dict(_changes_type= '_uncommitted_changes')),
56
dict(_changes_type= '_pending_merges')),
58
dict(_changes_type= '_out_of_sync_trees')),
60
tests.multiply_tests(changes_tests, changes_scenarios, result)
61
# No parametrization for the remaining tests
62
result.addTests(remaining_tests)
44
load_tests = scenarios.load_tests_apply_scenarios
67
47
class TestPush(tests.TestCaseWithTransport):
224
204
% tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
225
205
self.failUnlessExists('to-two')
207
def test_push_repository_no_branch_doesnt_fetch_all_revs(self):
208
# See https://bugs.launchpad.net/bzr/+bug/465517
209
target_repo = self.make_repository('target')
210
source = self.make_branch_builder('source')
211
source.start_series()
212
source.build_snapshot('A', None, [
213
('add', ('', 'root-id', 'directory', None))])
214
source.build_snapshot('B', ['A'], [])
215
source.build_snapshot('C', ['A'], [])
216
source.finish_series()
217
self.run_bzr('push target -d source')
218
self.addCleanup(target_repo.lock_read().unlock)
219
# We should have pushed 'C', but not 'B', since it isn't in the
221
self.assertEqual([('A',), ('C',)], sorted(target_repo.revisions.keys()))
227
223
def test_push_smart_non_stacked_streaming_acceptance(self):
228
224
self.setup_smart_server_with_call_log()
229
225
t = self.make_branch_and_tree('from')
251
247
# being too low. If rpc_count increases, more network roundtrips have
252
248
# become necessary for this use case. Please do not adjust this number
253
249
# upwards without agreement from bzr's network support maintainers.
254
self.assertLength(14, self.hpss_calls)
250
self.assertLength(13, self.hpss_calls)
255
251
remote = branch.Branch.open('public')
256
252
self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
729
725
self.assertPushSucceeds([])
728
strict_push_change_scenarios = [
730
dict(_changes_type= '_uncommitted_changes')),
732
dict(_changes_type= '_pending_merges')),
733
('out-of-sync-trees',
734
dict(_changes_type= '_out_of_sync_trees')),
732
738
class TestPushStrictWithChanges(tests.TestCaseWithTransport,
733
739
TestPushStrictMixin):
741
scenarios = strict_push_change_scenarios
735
742
_changes_type = None # Set by load_tests