~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009-2012 Canonical Ltd
 
1
# Copyright (C) 2009, 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
18
18
"""Black-box tests for bzr dpush."""
19
19
 
20
20
 
 
21
import os
 
22
 
21
23
from bzrlib import (
22
24
    branch,
 
25
    bzrdir,
 
26
    foreign,
23
27
    tests,
 
28
    workingtree,
24
29
    )
25
30
from bzrlib.tests import (
 
31
    blackbox,
26
32
    script,
27
33
    test_foreign,
28
34
    )
29
35
from bzrlib.tests.blackbox import test_push
30
 
from bzrlib.tests.scenarios import (
31
 
    load_tests_apply_scenarios,
32
 
    )
33
 
 
34
 
 
35
 
load_tests = load_tests_apply_scenarios
 
36
 
 
37
 
 
38
def load_tests(standard_tests, module, loader):
 
39
    """Multiply tests for the dpush command."""
 
40
    result = loader.suiteClass()
 
41
 
 
42
    # one for each king of change
 
43
    changes_tests, remaining_tests = tests.split_suite_by_condition(
 
44
        standard_tests, tests.condition_isinstance((
 
45
                TestDpushStrictWithChanges,
 
46
                )))
 
47
    changes_scenarios = [
 
48
        ('uncommitted',
 
49
         dict(_changes_type= '_uncommitted_changes')),
 
50
        ('pending-merges',
 
51
         dict(_changes_type= '_pending_merges')),
 
52
        ('out-of-sync-trees',
 
53
         dict(_changes_type= '_out_of_sync_trees')),
 
54
        ]
 
55
    tests.multiply_tests(changes_tests, changes_scenarios, result)
 
56
    # No parametrization for the remaining tests
 
57
    result.addTests(remaining_tests)
 
58
 
 
59
    return result
36
60
 
37
61
 
38
62
class TestDpush(tests.TestCaseWithTransport):
54
78
        source_tree = self.make_branch_and_tree("dc")
55
79
        output, error = self.run_bzr("dpush -d dc dp", retcode=3)
56
80
        self.assertEquals("", output)
57
 
        self.assertContainsRe(error,
58
 
            'in the same VCS, lossy push not necessary. Please use regular '
59
 
            'push.')
 
81
        self.assertContainsRe(error, 'in the same VCS, lossy push not necessary. Please use regular push.')
60
82
 
61
83
    def test_dpush(self):
62
84
        branch = self.make_dummy_builder('d').get_branch()
67
89
 
68
90
        script.run_script(self, """
69
91
            $ bzr dpush -d dc d
70
 
            2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
71
 
            2>This may take some time. Upgrade the repositories to the same format for better performance.
72
92
            2>Pushed up to revision 2.
73
93
            $ bzr status dc
74
94
            """)
84
104
 
85
105
        script.run_script(self, '''
86
106
            $ bzr dpush -d dc d
87
 
            2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
88
 
            2>This may take some time. Upgrade the repositories to the same format for better performance.
89
 
            2>Pushed up to revision 2.
90
107
            $ bzr revno dc
91
108
            2
92
109
            $ bzr status dc
104
121
        self.build_tree_contents([("dc/foofile", "blaaaal")])
105
122
        script.run_script(self, '''
106
123
            $ bzr dpush -d dc d --no-strict
107
 
            2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
108
 
            2>This may take some time. Upgrade the repositories to the same format for better performance.
109
 
            2>Pushed up to revision 2.
110
124
            ''')
111
125
        self.assertFileEqual("blaaaal", "dc/foofile")
112
126
        # if the dummy vcs wasn't that dummy we could uncomment the line below
145
159
            'to', format=test_foreign.DummyForeignVcsDirFormat())
146
160
 
147
161
    def set_config_push_strict(self, value):
148
 
        br = branch.Branch.open('local')
149
 
        br.get_config_stack().set('dpush_strict', value)
 
162
        # set config var (any of bazaar.conf, locations.conf, branch.conf
 
163
        # should do)
 
164
        conf = self.tree.branch.get_config()
 
165
        conf.set_user_option('dpush_strict', value)
150
166
 
151
167
    _default_command = ['dpush', '../to']
152
168
 
162
178
class TestDpushStrictWithChanges(TestDpushStrictMixin,
163
179
                                 test_push.TestPushStrictWithChanges):
164
180
 
165
 
    scenarios = test_push.strict_push_change_scenarios
166
 
 
167
181
    _changes_type = None # Set by load_tests
168
182
 
169
183
    def setUp(self):
172
186
 
173
187
    def test_push_with_revision(self):
174
188
        raise tests.TestNotApplicable('dpush does not handle --revision')
 
189