~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009-2012, 2016 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
22
    branch,
25
 
    bzrdir,
26
 
    foreign,
27
23
    tests,
28
 
    workingtree,
29
24
    )
30
25
from bzrlib.tests import (
31
 
    blackbox,
32
26
    script,
33
27
    test_foreign,
34
28
    )
35
29
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
 
30
from bzrlib.tests.scenarios import (
 
31
    load_tests_apply_scenarios,
 
32
    )
 
33
 
 
34
 
 
35
load_tests = load_tests_apply_scenarios
60
36
 
61
37
 
62
38
class TestDpush(tests.TestCaseWithTransport):
77
53
        target_tree = self.make_branch_and_tree("dp")
78
54
        source_tree = self.make_branch_and_tree("dc")
79
55
        output, error = self.run_bzr("dpush -d dc dp", retcode=3)
80
 
        self.assertEquals("", output)
81
 
        self.assertContainsRe(error, 'in the same VCS, lossy push not necessary. Please use regular push.')
 
56
        self.assertEqual("", output)
 
57
        self.assertContainsRe(error,
 
58
            'in the same VCS, lossy push not necessary. Please use regular '
 
59
            'push.')
82
60
 
83
61
    def test_dpush(self):
84
62
        branch = self.make_dummy_builder('d').get_branch()
89
67
 
90
68
        script.run_script(self, """
91
69
            $ 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.
92
72
            2>Pushed up to revision 2.
93
73
            $ bzr status dc
94
74
            """)
104
84
 
105
85
        script.run_script(self, '''
106
86
            $ 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.
107
90
            $ bzr revno dc
108
91
            2
109
92
            $ bzr status dc
121
104
        self.build_tree_contents([("dc/foofile", "blaaaal")])
122
105
        script.run_script(self, '''
123
106
            $ 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.
124
110
            ''')
125
111
        self.assertFileEqual("blaaaal", "dc/foofile")
126
112
        # if the dummy vcs wasn't that dummy we could uncomment the line below
146
132
          [('modify', ('fooid', 'blie'))])
147
133
 
148
134
        output, error = self.run_bzr("dpush -d dc d", retcode=3)
149
 
        self.assertEquals(output, "")
 
135
        self.assertEqual(output, "")
150
136
        self.assertContainsRe(error, "have diverged")
151
137
 
152
138
 
159
145
            'to', format=test_foreign.DummyForeignVcsDirFormat())
160
146
 
161
147
    def set_config_push_strict(self, 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)
 
148
        br = branch.Branch.open('local')
 
149
        br.get_config_stack().set('dpush_strict', value)
166
150
 
167
151
    _default_command = ['dpush', '../to']
168
152
 
178
162
class TestDpushStrictWithChanges(TestDpushStrictMixin,
179
163
                                 test_push.TestPushStrictWithChanges):
180
164
 
 
165
    scenarios = test_push.strict_push_change_scenarios
 
166
 
181
167
    _changes_type = None # Set by load_tests
182
168
 
183
169
    def setUp(self):
186
172
 
187
173
    def test_push_with_revision(self):
188
174
        raise tests.TestNotApplicable('dpush does not handle --revision')
189