~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Marius Kruger
  • Date: 2007-06-27 18:48:10 UTC
  • mfrom: (2557 +trunk)
  • mto: (2605.1.1 rm-renamed)
  • mto: This revision was merged to the branch mainline in revision 2609.
  • Revision ID: marius.kruger@enerweb.co.za-20070627184810-4jq1y5f20xafow9w
Merge with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
class TestPull(ExternalBase):
30
30
 
31
31
    def example_branch(test):
32
 
        test.runbzr('init')
 
32
        test.run_bzr('init')
33
33
        file('hello', 'wt').write('foo')
34
 
        test.runbzr('add hello')
35
 
        test.runbzr('commit -m setup hello')
 
34
        test.run_bzr('add hello')
 
35
        test.run_bzr('commit -m setup hello')
36
36
        file('goodbye', 'wt').write('baz')
37
 
        test.runbzr('add goodbye')
38
 
        test.runbzr('commit -m setup goodbye')
 
37
        test.run_bzr('add goodbye')
 
38
        test.run_bzr('commit -m setup goodbye')
39
39
 
40
40
    def test_pull(self):
41
41
        """Pull changes from one branch to another."""
43
43
        os.chdir('a')
44
44
 
45
45
        self.example_branch()
46
 
        self.runbzr('pull', retcode=3)
47
 
        self.runbzr('missing', retcode=3)
48
 
        self.runbzr('missing .')
49
 
        self.runbzr('missing')
 
46
        self.run_bzr('pull', retcode=3)
 
47
        self.run_bzr('missing', retcode=3)
 
48
        self.run_bzr('missing .')
 
49
        self.run_bzr('missing')
50
50
        # this will work on windows because we check for the same branch
51
51
        # in pull - if it fails, it is a regression
52
 
        self.runbzr('pull')
53
 
        self.runbzr('pull /', retcode=3)
 
52
        self.run_bzr('pull')
 
53
        self.run_bzr('pull /', retcode=3)
54
54
        if sys.platform not in ('win32', 'cygwin'):
55
 
            self.runbzr('pull')
 
55
            self.run_bzr('pull')
56
56
 
57
57
        os.chdir('..')
58
 
        self.runbzr('branch a b')
 
58
        self.run_bzr('branch a b')
59
59
        os.chdir('b')
60
 
        self.runbzr('pull')
 
60
        self.run_bzr('pull')
61
61
        os.mkdir('subdir')
62
 
        self.runbzr('add subdir')
63
 
        self.runbzr('commit -m blah --unchanged')
 
62
        self.run_bzr('add subdir')
 
63
        self.run_bzr('commit -m blah --unchanged')
64
64
        os.chdir('../a')
65
65
        a = Branch.open('.')
66
66
        b = Branch.open('../b')
67
67
        self.assertEquals(a.revision_history(), b.revision_history()[:-1])
68
 
        self.runbzr('pull ../b')
 
68
        self.run_bzr('pull ../b')
69
69
        self.assertEquals(a.revision_history(), b.revision_history())
70
 
        self.runbzr('commit -m blah2 --unchanged')
 
70
        self.run_bzr('commit -m blah2 --unchanged')
71
71
        os.chdir('../b')
72
 
        self.runbzr('commit -m blah3 --unchanged')
 
72
        self.run_bzr('commit -m blah3 --unchanged')
73
73
        # no overwrite
74
 
        self.runbzr('pull ../a', retcode=3)
 
74
        self.run_bzr('pull ../a', retcode=3)
75
75
        os.chdir('..')
76
 
        self.runbzr('branch b overwriteme')
 
76
        self.run_bzr('branch b overwriteme')
77
77
        os.chdir('overwriteme')
78
 
        self.runbzr('pull --overwrite ../a')
 
78
        self.run_bzr('pull --overwrite ../a')
79
79
        overwritten = Branch.open('.')
80
80
        self.assertEqual(overwritten.revision_history(),
81
81
                         a.revision_history())
82
82
        os.chdir('../a')
83
 
        self.runbzr('merge ../b')
84
 
        self.runbzr('commit -m blah4 --unchanged')
 
83
        self.run_bzr('merge ../b')
 
84
        self.run_bzr('commit -m blah4 --unchanged')
85
85
        os.chdir('../b/subdir')
86
 
        self.runbzr('pull ../../a')
 
86
        self.run_bzr('pull ../../a')
87
87
        self.assertEquals(a.revision_history()[-1], b.revision_history()[-1])
88
 
        self.runbzr('commit -m blah5 --unchanged')
89
 
        self.runbzr('commit -m blah6 --unchanged')
 
88
        self.run_bzr('commit -m blah5 --unchanged')
 
89
        self.run_bzr('commit -m blah6 --unchanged')
90
90
        os.chdir('..')
91
 
        self.runbzr('pull ../a')
 
91
        self.run_bzr('pull ../a')
92
92
        os.chdir('../a')
93
 
        self.runbzr('commit -m blah7 --unchanged')
94
 
        self.runbzr('merge ../b')
95
 
        self.runbzr('commit -m blah8 --unchanged')
96
 
        self.runbzr('pull ../b')
97
 
        self.runbzr('pull ../b')
 
93
        self.run_bzr('commit -m blah7 --unchanged')
 
94
        self.run_bzr('merge ../b')
 
95
        self.run_bzr('commit -m blah8 --unchanged')
 
96
        self.run_bzr('pull ../b')
 
97
        self.run_bzr('pull ../b')
98
98
 
99
99
    def test_pull_dash_d(self):
100
100
        os.mkdir('a')
101
101
        os.chdir('a')
102
102
        self.example_branch()
103
 
        self.runbzr('init ../b')
104
 
        self.runbzr('init ../c')
 
103
        self.run_bzr('init ../b')
 
104
        self.run_bzr('init ../c')
105
105
        # pull into that branch
106
 
        self.runbzr('pull -d ../b .')
 
106
        self.run_bzr('pull -d ../b .')
107
107
        # pull into a branch specified by a url
108
108
        c_url = urlutils.local_path_to_url('../c')
109
109
        self.assertStartsWith(c_url, 'file://')
110
 
        self.runbzr('pull -d %s .' % c_url)
 
110
        self.run_bzr('pull -d %s .' % c_url)
111
111
 
112
112
    def test_pull_revision(self):
113
113
        """Pull some changes from one branch to another."""
116
116
 
117
117
        self.example_branch()
118
118
        file('hello2', 'wt').write('foo')
119
 
        self.runbzr('add hello2')
120
 
        self.runbzr('commit -m setup hello2')
 
119
        self.run_bzr('add hello2')
 
120
        self.run_bzr('commit -m setup hello2')
121
121
        file('goodbye2', 'wt').write('baz')
122
 
        self.runbzr('add goodbye2')
123
 
        self.runbzr('commit -m setup goodbye2')
 
122
        self.run_bzr('add goodbye2')
 
123
        self.run_bzr('commit -m setup goodbye2')
124
124
 
125
125
        os.chdir('..')
126
 
        self.runbzr('branch -r 1 a b')
 
126
        self.run_bzr('branch -r 1 a b')
127
127
        os.chdir('b')
128
 
        self.runbzr('pull -r 2')
 
128
        self.run_bzr('pull -r 2')
129
129
        a = Branch.open('../a')
130
130
        b = Branch.open('.')
131
131
        self.assertEquals(a.revno(),4)
132
132
        self.assertEquals(b.revno(),2)
133
 
        self.runbzr('pull -r 3')
 
133
        self.run_bzr('pull -r 3')
134
134
        self.assertEquals(b.revno(),3)
135
 
        self.runbzr('pull -r 4')
 
135
        self.run_bzr('pull -r 4')
136
136
        self.assertEquals(a.revision_history(), b.revision_history())
137
137
 
138
138
 
143
143
        bzr = self.run_bzr
144
144
 
145
145
        def get_rh(expected_len):
146
 
            rh = self.capture('revision-history')
 
146
            rh = self.run_bzr(['revision-history'])[0]
147
147
            # Make sure we don't have trailing empty revisions
148
148
            rh = rh.strip().split('\n')
149
149
            self.assertEqual(len(rh), expected_len)
185
185
        bzr = self.run_bzr
186
186
 
187
187
        def get_rh(expected_len):
188
 
            rh = self.capture('revision-history')
 
188
            rh = self.run_bzr(['revision-history'])[0]
189
189
            # Make sure we don't have trailing empty revisions
190
190
            rh = rh.strip().split('\n')
191
191
            self.assertEqual(len(rh), expected_len)
251
251
        self.assertEqual(None, branch_b.get_parent())
252
252
        # test pull for failure without parent set
253
253
        os.chdir('branch_b')
254
 
        out = self.runbzr('pull', retcode=3)
 
254
        out = self.run_bzr('pull', retcode=3)
255
255
        self.assertEquals(out,
256
256
                ('','bzr: ERROR: No pull location known or specified.\n'))
257
257
        # test implicit --remember when no parent set, this pull conflicts
258
258
        self.build_tree(['d'])
259
259
        tree_b.add('d')
260
260
        tree_b.commit('commit d')
261
 
        out = self.runbzr('pull ../branch_a', retcode=3)
 
261
        out = self.run_bzr('pull ../branch_a', retcode=3)
262
262
        self.assertEquals(out,
263
263
                ('','bzr: ERROR: These branches have diverged.'
264
264
                    ' Use the merge command to reconcile them.\n'))
266
266
        # test implicit --remember after resolving previous failure
267
267
        uncommit(branch=branch_b, tree=tree_b)
268
268
        transport.delete('branch_b/d')
269
 
        self.runbzr('pull')
 
269
        self.run_bzr('pull')
270
270
        self.assertEquals(branch_b.get_parent(), parent)
271
271
        # test explicit --remember
272
 
        self.runbzr('pull ../branch_c --remember')
 
272
        self.run_bzr('pull ../branch_c --remember')
273
273
        self.assertEquals(branch_b.get_parent(),
274
274
                          branch_c.bzrdir.root_transport.base)
275
275