~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge bzr.dev, update to use new hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009, 2010, 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
18
18
"""Black-box tests for bzr dpush."""
19
19
 
20
20
 
21
 
import os
22
 
 
23
21
from bzrlib import (
24
 
    branch,
25
 
    bzrdir,
26
 
    foreign,
27
22
    tests,
28
 
    workingtree,
29
23
    )
30
24
from bzrlib.tests import (
31
 
    blackbox,
32
25
    script,
33
26
    test_foreign,
34
27
    )
35
28
from bzrlib.tests.blackbox import test_push
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
 
29
from bzrlib.tests.scenarios import (
 
30
    load_tests_apply_scenarios,
 
31
    )
 
32
 
 
33
 
 
34
load_tests = load_tests_apply_scenarios
60
35
 
61
36
 
62
37
class TestDpush(tests.TestCaseWithTransport):
78
53
        source_tree = self.make_branch_and_tree("dc")
79
54
        output, error = self.run_bzr("dpush -d dc dp", retcode=3)
80
55
        self.assertEquals("", output)
81
 
        self.assertContainsRe(error, 'in the same VCS, lossy push not necessary. Please use regular push.')
 
56
        self.assertContainsRe(error,
 
57
            'in the same VCS, lossy push not necessary. Please use regular '
 
58
            'push.')
82
59
 
83
60
    def test_dpush(self):
84
61
        branch = self.make_dummy_builder('d').get_branch()
89
66
 
90
67
        script.run_script(self, """
91
68
            $ bzr dpush -d dc d
 
69
            2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
 
70
            2>This may take some time. Upgrade the repositories to the same format for better performance.
92
71
            2>Pushed up to revision 2.
93
72
            $ bzr status dc
94
73
            """)
104
83
 
105
84
        script.run_script(self, '''
106
85
            $ bzr dpush -d dc d
 
86
            2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
 
87
            2>This may take some time. Upgrade the repositories to the same format for better performance.
 
88
            2>Pushed up to revision 2.
107
89
            $ bzr revno dc
108
90
            2
109
91
            $ bzr status dc
121
103
        self.build_tree_contents([("dc/foofile", "blaaaal")])
122
104
        script.run_script(self, '''
123
105
            $ bzr dpush -d dc d --no-strict
 
106
            2>Doing on-the-fly conversion from DummyForeignVcsRepositoryFormat() to RepositoryFormat2a().
 
107
            2>This may take some time. Upgrade the repositories to the same format for better performance.
 
108
            2>Pushed up to revision 2.
124
109
            ''')
125
110
        self.assertFileEqual("blaaaal", "dc/foofile")
126
111
        # if the dummy vcs wasn't that dummy we could uncomment the line below
161
146
    def set_config_push_strict(self, value):
162
147
        # set config var (any of bazaar.conf, locations.conf, branch.conf
163
148
        # should do)
164
 
        conf = self.tree.branch.get_config()
165
 
        conf.set_user_option('dpush_strict', value)
 
149
        conf = self.tree.branch.get_config_stack()
 
150
        conf.set('dpush_strict', value)
166
151
 
167
152
    _default_command = ['dpush', '../to']
168
153
 
178
163
class TestDpushStrictWithChanges(TestDpushStrictMixin,
179
164
                                 test_push.TestPushStrictWithChanges):
180
165
 
 
166
    scenarios = test_push.strict_push_change_scenarios
 
167
 
181
168
    _changes_type = None # Set by load_tests
182
169
 
183
170
    def setUp(self):
186
173
 
187
174
    def test_push_with_revision(self):
188
175
        raise tests.TestNotApplicable('dpush does not handle --revision')
189