29
29
class TestPull(ExternalBase):
31
31
def example_branch(test):
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')
40
40
def test_pull(self):
41
41
"""Pull changes from one branch to another."""
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
53
self.runbzr('pull /', retcode=3)
53
self.run_bzr('pull /', retcode=3)
54
54
if sys.platform not in ('win32', 'cygwin'):
58
self.runbzr('branch a b')
58
self.run_bzr('branch a b')
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')
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')
72
self.runbzr('commit -m blah3 --unchanged')
72
self.run_bzr('commit -m blah3 --unchanged')
74
self.runbzr('pull ../a', retcode=3)
74
self.run_bzr('pull ../a', retcode=3)
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())
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')
91
self.runbzr('pull ../a')
91
self.run_bzr('pull ../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')
99
99
def test_pull_dash_d(self):
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)
112
112
def test_pull_revision(self):
113
113
"""Pull some changes from one branch to another."""
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')
126
self.runbzr('branch -r 1 a b')
126
self.run_bzr('branch -r 1 a 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())
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'])
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'))