7
7
file(filename, 'wb').write('')
9
9
def test_clean_tree(self):
11
self.runbzr('ignore *~')
12
self.runbzr('ignore *.pyc')
11
self.run_bzr('ignore *~')
12
self.run_bzr('ignore *.pyc')
14
14
self.touch('name~')
15
15
assert os.path.lexists('name~')
16
16
self.touch('name.pyc')
17
self.runbzr('clean-tree')
17
self.run_bzr('clean-tree')
18
18
assert os.path.lexists('name~')
19
19
assert not os.path.lexists('name')
21
self.runbzr('clean-tree --detritus')
21
self.run_bzr('clean-tree --detritus')
22
22
assert os.path.lexists('name')
23
23
assert not os.path.lexists('name~')
24
24
assert os.path.lexists('name.pyc')
25
self.runbzr('clean-tree --ignored')
25
self.run_bzr('clean-tree --ignored')
26
26
assert os.path.lexists('name')
27
27
assert not os.path.lexists('name.pyc')
28
self.runbzr('clean-tree --unknown')
28
self.run_bzr('clean-tree --unknown')
29
29
assert not os.path.lexists('name')
31
31
self.touch('name~')
32
32
self.touch('name.pyc')
33
self.runbzr('clean-tree --unknown --ignored')
33
self.run_bzr('clean-tree --unknown --ignored')
34
34
assert not os.path.lexists('name')
35
35
assert not os.path.lexists('name~')
36
36
assert not os.path.lexists('name.pyc')
38
38
def test_shelve(self):
40
self.runbzr('commit -m uc --unchanged')
41
self.runbzr('shelve -r 1 -m foo --all', retcode=3)
40
self.run_bzr('commit -m uc --unchanged')
41
self.run_bzr('shelve -r 1 -m foo --all', retcode=3)
42
42
file('foo', 'wb').write('foo')
43
self.runbzr('add foo')
44
self.runbzr('commit -m foo')
45
self.runbzr('shelve -r 1 -m foo --all', retcode=0)
43
self.run_bzr('add foo')
44
self.run_bzr('commit -m foo')
45
self.run_bzr('shelve -r 1 -m foo --all', retcode=0)
47
47
def test_fetch_ghosts(self):
49
self.runbzr('fetch-ghosts .')
49
self.run_bzr('fetch-ghosts .')
51
51
def test_patch(self):
53
53
file('myfile', 'wb').write('hello')
55
self.runbzr('commit -m hello')
55
self.run_bzr('commit -m hello')
56
56
file('myfile', 'wb').write('goodbye')
57
file('mypatch', 'wb').write(self.runbzr('diff', retcode=1, backtick=1))
57
file('mypatch', 'wb').write(self.run_bzr('diff', retcode=1)[0])
58
self.run_bzr('revert')
59
59
assert file('myfile', 'rb').read() == 'hello'
60
self.runbzr('patch mypatch')
60
self.run_bzr('patch --silent mypatch')
61
61
assert file('myfile', 'rb').read() == 'goodbye'
63
63
def test_branch_history(self):
65
65
file('myfile', 'wb').write('hello')
67
self.runbzr('commit -m hello')
68
self.runbzr('branch-history')
67
self.run_bzr('commit -m hello')
68
self.run_bzr('branch-history')
70
70
def test_branch_history(self):
72
72
file('myfile', 'wb').write('hello')
74
self.runbzr('commit -m hello')
75
self.runbzr('graph-ancestry . graph.dot')
76
self.runbzr('branch . my_branch')
77
self.runbzr('graph-ancestry . graph.dot --merge-branch my_branch')
74
self.run_bzr('commit -m hello')
75
self.run_bzr('graph-ancestry . graph.dot')
76
self.run_bzr('branch . my_branch')
77
self.run_bzr('graph-ancestry . graph.dot --merge-branch my_branch')
79
79
def test_fetch_ghosts(self):
81
81
file('myfile', 'wb').write('hello')
83
self.runbzr('commit -m hello')
84
self.runbzr('branch . my_branch')
85
self.runbzr('fetch-ghosts my_branch')
83
self.run_bzr('commit -m hello')
84
self.run_bzr('branch . my_branch')
85
self.run_bzr('fetch-ghosts my_branch')
87
87
def test_zap(self):
88
self.runbzr('init source')
89
self.runbzr('checkout --lightweight source checkout')
90
self.runbzr('zap checkout')
88
self.run_bzr('init source')
89
self.run_bzr('checkout --lightweight source checkout')
90
self.run_bzr('zap checkout')
91
91
self.assertIs(False, os.path.exists('checkout'))
92
92
self.assertIs(True, os.path.exists('source'))
94
94
def test_zap_branch(self):
95
self.runbzr('init source')
96
self.runbzr('checkout --lightweight source checkout')
97
self.runbzr('zap --branch checkout', retcode=3)
95
self.run_bzr('init source')
96
self.run_bzr('checkout --lightweight source checkout')
97
self.run_bzr('zap --branch checkout', retcode=3)
98
98
self.assertIs(True, os.path.exists('checkout'))
99
99
self.assertIs(True, os.path.exists('source'))
100
self.runbzr('branch source source2')
101
self.runbzr('checkout --lightweight source2 checkout2')
102
self.runbzr('zap --branch checkout2')
100
self.run_bzr('branch source source2')
101
self.run_bzr('checkout --lightweight source2 checkout2')
102
self.run_bzr('zap --branch checkout2')
103
103
self.assertIs(False, os.path.exists('checkout2'))
104
104
self.assertIs(False, os.path.exists('source2'))
106
106
def test_branches(self):
107
self.runbzr('init source')
108
self.runbzr('init source/subsource')
109
self.runbzr('checkout --lightweight source checkout')
110
self.runbzr('init checkout/subcheckout')
111
self.runbzr('init checkout/.bzr/subcheckout')
112
out = self.capture('branches')
107
self.run_bzr('init source')
108
self.run_bzr('init source/subsource')
109
self.run_bzr('checkout --lightweight source checkout')
110
self.run_bzr('init checkout/subcheckout')
111
self.run_bzr('init checkout/.bzr/subcheckout')
112
out = self.run_bzr('branches')[0]
113
113
lines = out.split('\n')
114
114
self.assertIs(True, 'source' in lines)
115
115
self.assertIs(True, 'source/subsource' in lines)
118
118
self.assertIs(True, 'checkout/.bzr/subcheckout' not in lines)
120
120
def test_import_upstream(self):
121
self.runbzr('init source')
121
self.run_bzr('init source')
122
122
os.mkdir('source/src')
123
123
f = file('source/src/myfile', 'wb')
124
124
f.write('hello?')
126
126
os.chdir('source')
128
self.runbzr('commit -m hello')
129
self.runbzr('export ../source-0.1.tar.gz')
130
self.runbzr('export ../source-0.1.tar.bz2')
131
self.runbzr('init ../import')
128
self.run_bzr('commit -m hello')
129
self.run_bzr('export ../source-0.1.tar.gz')
130
self.run_bzr('export ../source-0.1.tar.bz2')
131
self.run_bzr('export ../source-0.1')
132
self.run_bzr('init ../import')
132
133
os.chdir('../import')
133
self.runbzr('import ../source-0.1.tar.gz')
134
self.run_bzr('import ../source-0.1.tar.gz')
134
135
self.failUnlessExists('src/myfile')
135
result = self.runbzr('import ../source-0.1.tar.gz', retcode=3)[1]
136
result = self.run_bzr('import ../source-0.1.tar.gz', retcode=3)[1]
136
137
self.assertContainsRe(result, 'Working tree has uncommitted changes')
137
self.runbzr('commit -m commit')
138
self.runbzr('import ../source-0.1.tar.gz')
138
self.run_bzr('commit -m commit')
139
self.run_bzr('import ../source-0.1.tar.gz')
140
self.runbzr('init import2')
141
self.runbzr('import source-0.1.tar.gz import2')
141
self.run_bzr('init import2')
142
self.run_bzr('import source-0.1.tar.gz import2')
142
143
self.failUnlessExists('import2/src/myfile')
143
self.runbzr('import source-0.1.tar.gz import3')
144
self.run_bzr('import source-0.1.tar.gz import3')
144
145
self.failUnlessExists('import3/src/myfile')
145
self.runbzr('import source-0.1.tar.bz2 import4')
146
self.run_bzr('import source-0.1.tar.bz2 import4')
146
147
self.failUnlessExists('import4/src/myfile')
148
self.run_bzr('import source-0.1 import5')
149
self.failUnlessExists('import5/src/myfile')
148
151
def test_suite():
149
152
return makeSuite(TestBzrTools)