~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_push.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-29 08:40:34 UTC
  • mfrom: (6107.1.1 trivial)
  • Revision ID: pqm@pqm.ubuntu.com-20110829084034-vzt7yztscr89cxb6
(mbp) top-level doc page should now point to whatsnew-2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
#
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 (
35
35
    blackbox,
36
36
    http_server,
 
37
    scenarios,
37
38
    test_foreign,
38
39
    test_server,
39
40
    )
40
41
from bzrlib.transport import memory
41
42
 
42
43
 
43
 
def load_tests(standard_tests, module, loader):
44
 
    """Multiply tests for the push command."""
45
 
    result = loader.suiteClass()
46
 
 
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,
51
 
                )))
52
 
    changes_scenarios = [
53
 
        ('uncommitted',
54
 
         dict(_changes_type= '_uncommitted_changes')),
55
 
        ('pending-merges',
56
 
         dict(_changes_type= '_pending_merges')),
57
 
        ('out-of-sync-trees',
58
 
         dict(_changes_type= '_out_of_sync_trees')),
59
 
        ]
60
 
    tests.multiply_tests(changes_tests, changes_scenarios, result)
61
 
    # No parametrization for the remaining tests
62
 
    result.addTests(remaining_tests)
63
 
 
64
 
    return result
 
44
load_tests = scenarios.load_tests_apply_scenarios
65
45
 
66
46
 
67
47
class TestPush(tests.TestCaseWithTransport):
124
104
        transport.delete('branch_b/c')
125
105
        out, err = self.run_bzr('push', working_dir='branch_a')
126
106
        path = branch_a.get_push_location()
127
 
        self.assertEquals(out,
128
 
                          'Using saved push location: %s\n'
129
 
                          % urlutils.local_path_from_url(path))
130
107
        self.assertEqual(err,
 
108
                         'Using saved push location: %s\n'
131
109
                         'All changes applied successfully.\n'
132
 
                         'Pushed up to revision 2.\n')
 
110
                         'Pushed up to revision 2.\n'
 
111
                         % urlutils.local_path_from_url(path))
133
112
        self.assertEqual(path,
134
113
                         branch_b.bzrdir.root_transport.base)
135
114
        # test explicit --remember
146
125
        b2 = branch.Branch.open('pushed-location')
147
126
        self.assertEndsWith(b2.base, 'pushed-location/')
148
127
 
 
128
    def test_push_no_tree(self):
 
129
        # bzr push --no-tree of a branch with working trees
 
130
        b = self.make_branch_and_tree('push-from')
 
131
        self.build_tree(['push-from/file'])
 
132
        b.add('file')
 
133
        b.commit('commit 1')
 
134
        out, err = self.run_bzr('push --no-tree -d push-from push-to')
 
135
        self.assertEqual('', out)
 
136
        self.assertEqual('Created new branch.\n', err)
 
137
        self.assertPathDoesNotExist('push-to/file')
 
138
 
149
139
    def test_push_new_branch_revision_count(self):
150
140
        # bzr push of a branch with revisions to a new location
151
141
        # should print the number of revisions equal to the length of the
158
148
        self.assertEqual('', out)
159
149
        self.assertEqual('Created new branch.\n', err)
160
150
 
 
151
    def test_push_quiet(self):
 
152
        # test that using -q makes output quiet
 
153
        t = self.make_branch_and_tree('tree')
 
154
        self.build_tree(['tree/file'])
 
155
        t.add('file')
 
156
        t.commit('commit 1')
 
157
        self.run_bzr('push -d tree pushed-to')
 
158
        path = t.branch.get_push_location()
 
159
        out, err = self.run_bzr('push', working_dir="tree")
 
160
        self.assertEqual('Using saved push location: %s\nNo new revisions to push.\n' % urlutils.local_path_from_url(path), err)
 
161
        out, err = self.run_bzr('push -q', working_dir="tree")
 
162
        self.assertEqual('', out)
 
163
        self.assertEqual('', err)
 
164
 
161
165
    def test_push_only_pushes_history(self):
162
166
        # Knit branches should only push the history for the current revision.
163
167
        format = bzrdir.BzrDirMetaFormat1()
208
212
        t.commit(allow_pointless=True,
209
213
                message='first commit')
210
214
        self.run_bzr('push -d from to-one')
211
 
        self.failUnlessExists('to-one')
 
215
        self.assertPathExists('to-one')
212
216
        self.run_bzr('push -d %s %s'
213
217
            % tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
214
 
        self.failUnlessExists('to-two')
 
218
        self.assertPathExists('to-two')
 
219
 
 
220
    def test_push_repository_no_branch_doesnt_fetch_all_revs(self):
 
221
        # See https://bugs.launchpad.net/bzr/+bug/465517
 
222
        target_repo = self.make_repository('target')
 
223
        source = self.make_branch_builder('source')
 
224
        source.start_series()
 
225
        source.build_snapshot('A', None, [
 
226
            ('add', ('', 'root-id', 'directory', None))])
 
227
        source.build_snapshot('B', ['A'], [])
 
228
        source.build_snapshot('C', ['A'], [])
 
229
        source.finish_series()
 
230
        self.run_bzr('push target -d source')
 
231
        self.addCleanup(target_repo.lock_read().unlock)
 
232
        # We should have pushed 'C', but not 'B', since it isn't in the
 
233
        # ancestry
 
234
        self.assertEqual([('A',), ('C',)], sorted(target_repo.revisions.keys()))
215
235
 
216
236
    def test_push_smart_non_stacked_streaming_acceptance(self):
217
237
        self.setup_smart_server_with_call_log()
240
260
        # being too low. If rpc_count increases, more network roundtrips have
241
261
        # become necessary for this use case. Please do not adjust this number
242
262
        # upwards without agreement from bzr's network support maintainers.
243
 
        self.assertLength(14, self.hpss_calls)
 
263
        self.assertLength(13, self.hpss_calls)
244
264
        remote = branch.Branch.open('public')
245
265
        self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
246
266
 
317
337
                     working_dir='tree')
318
338
        new_tree = workingtree.WorkingTree.open('new/tree')
319
339
        self.assertEqual(tree.last_revision(), new_tree.last_revision())
320
 
        self.failUnlessExists('new/tree/a')
 
340
        self.assertPathExists('new/tree/a')
321
341
 
322
342
    def test_push_use_existing(self):
323
343
        """'bzr push --use-existing-dir' can push into an existing dir.
338
358
        new_tree = workingtree.WorkingTree.open('target')
339
359
        self.assertEqual(tree.last_revision(), new_tree.last_revision())
340
360
        # The push should have created target/a
341
 
        self.failUnlessExists('target/a')
 
361
        self.assertPathExists('target/a')
342
362
 
343
363
    def test_push_use_existing_into_empty_bzrdir(self):
344
364
        """'bzr push --use-existing-dir' into a dir with an empty .bzr dir
718
738
        self.assertPushSucceeds([])
719
739
 
720
740
 
 
741
strict_push_change_scenarios = [
 
742
    ('uncommitted',
 
743
        dict(_changes_type= '_uncommitted_changes')),
 
744
    ('pending-merges',
 
745
        dict(_changes_type= '_pending_merges')),
 
746
    ('out-of-sync-trees',
 
747
        dict(_changes_type= '_out_of_sync_trees')),
 
748
    ]
 
749
 
 
750
 
721
751
class TestPushStrictWithChanges(tests.TestCaseWithTransport,
722
752
                                TestPushStrictMixin):
723
753
 
 
754
    scenarios = strict_push_change_scenarios 
724
755
    _changes_type = None # Set by load_tests
725
756
 
726
757
    def setUp(self):