~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Rory Yorke
  • Date: 2010-10-20 14:38:53 UTC
  • mto: This revision was merged to the branch mainline in revision 5519.
  • Revision ID: rory.yorke@gmail.com-20101020143853-9kfd2ldcjfroh8jw
Show missing files in bzr status (bug 134168).

"bzr status" will now show missing files, that is, those added with "bzr
add" and then removed by non bzr means (e.g., rm).

Blackbox tests were added for this case, and tests were also added to
test_delta, since the implementation change is in bzrlib.delta.

Might also affect bug 189709.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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,
38
37
    test_foreign,
39
38
    test_server,
40
39
    )
41
40
from bzrlib.transport import memory
42
41
 
43
42
 
44
 
load_tests = scenarios.load_tests_apply_scenarios
 
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
45
65
 
46
66
 
47
67
class TestPush(tests.TestCaseWithTransport):
135
155
        out, err = self.run_bzr('push --no-tree -d push-from push-to')
136
156
        self.assertEqual('', out)
137
157
        self.assertEqual('Created new branch.\n', err)
138
 
        self.assertPathDoesNotExist('push-to/file')
 
158
        self.failIfExists('push-to/file')
139
159
 
140
160
    def test_push_new_branch_revision_count(self):
141
161
        # bzr push of a branch with revisions to a new location
199
219
        t.commit(allow_pointless=True,
200
220
                message='first commit')
201
221
        self.run_bzr('push -d from to-one')
202
 
        self.assertPathExists('to-one')
 
222
        self.failUnlessExists('to-one')
203
223
        self.run_bzr('push -d %s %s'
204
224
            % tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
205
 
        self.assertPathExists('to-two')
206
 
 
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
220
 
        # ancestry
221
 
        self.assertEqual([('A',), ('C',)], sorted(target_repo.revisions.keys()))
 
225
        self.failUnlessExists('to-two')
222
226
 
223
227
    def test_push_smart_non_stacked_streaming_acceptance(self):
224
228
        self.setup_smart_server_with_call_log()
247
251
        # being too low. If rpc_count increases, more network roundtrips have
248
252
        # become necessary for this use case. Please do not adjust this number
249
253
        # upwards without agreement from bzr's network support maintainers.
250
 
        self.assertLength(13, self.hpss_calls)
 
254
        self.assertLength(14, self.hpss_calls)
251
255
        remote = branch.Branch.open('public')
252
256
        self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
253
257
 
324
328
                     working_dir='tree')
325
329
        new_tree = workingtree.WorkingTree.open('new/tree')
326
330
        self.assertEqual(tree.last_revision(), new_tree.last_revision())
327
 
        self.assertPathExists('new/tree/a')
 
331
        self.failUnlessExists('new/tree/a')
328
332
 
329
333
    def test_push_use_existing(self):
330
334
        """'bzr push --use-existing-dir' can push into an existing dir.
345
349
        new_tree = workingtree.WorkingTree.open('target')
346
350
        self.assertEqual(tree.last_revision(), new_tree.last_revision())
347
351
        # The push should have created target/a
348
 
        self.assertPathExists('target/a')
 
352
        self.failUnlessExists('target/a')
349
353
 
350
354
    def test_push_use_existing_into_empty_bzrdir(self):
351
355
        """'bzr push --use-existing-dir' into a dir with an empty .bzr dir
725
729
        self.assertPushSucceeds([])
726
730
 
727
731
 
728
 
strict_push_change_scenarios = [
729
 
    ('uncommitted',
730
 
        dict(_changes_type= '_uncommitted_changes')),
731
 
    ('pending-merges',
732
 
        dict(_changes_type= '_pending_merges')),
733
 
    ('out-of-sync-trees',
734
 
        dict(_changes_type= '_out_of_sync_trees')),
735
 
    ]
736
 
 
737
 
 
738
732
class TestPushStrictWithChanges(tests.TestCaseWithTransport,
739
733
                                TestPushStrictMixin):
740
734
 
741
 
    scenarios = strict_push_change_scenarios 
742
735
    _changes_type = None # Set by load_tests
743
736
 
744
737
    def setUp(self):