1
from bzrlib.tests.blackbox import ExternalBase
2
from unittest import makeSuite
4
class TestBzrTools(ExternalBase):
7
file(filename, 'wb').write('')
9
def test_clean_tree(self):
13
assert os.path.lexists('name~')
14
self.touch('name.pyc')
15
self.runbzr('clean-tree')
16
assert os.path.lexists('name~')
17
assert not os.path.lexists('name')
18
self.runbzr('clean-tree --detritus')
19
assert not os.path.lexists('name~')
20
assert os.path.lexists('name.pyc')
21
self.runbzr('clean-tree --ignored')
22
assert not os.path.lexists('name.pyc')
24
def test_shelve(self):
26
self.runbzr('commit -m uc --unchanged')
27
self.runbzr('shelve -r 1 -m foo --all', retcode=3)
28
file('foo', 'wb').write('foo')
29
self.runbzr('add foo')
30
self.runbzr('commit -m foo')
31
self.runbzr('shelve -r 1 -m foo --all', retcode=0)
33
def test_fetch_ghosts(self):
35
self.runbzr('fetch-ghosts .')
39
file('myfile', 'wb').write('hello')
41
self.runbzr('commit -m hello')
42
file('myfile', 'wb').write('goodbye')
43
file('mypatch', 'wb').write(self.runbzr('diff', retcode=1, backtick=1))
45
assert file('myfile', 'rb').read() == 'hello'
46
self.runbzr('patch mypatch')
47
assert file('myfile', 'rb').read() == 'goodbye'
49
def test_branch_history(self):
51
file('myfile', 'wb').write('hello')
53
self.runbzr('commit -m hello')
54
self.runbzr('branch-history')
56
def test_branch_history(self):
58
file('myfile', 'wb').write('hello')
60
self.runbzr('commit -m hello')
61
self.runbzr('graph-ancestry . graph.dot')
62
self.runbzr('branch . my_branch')
63
self.runbzr('graph-ancestry . graph.dot --merge-branch my_branch')
65
def test_fetch_ghosts(self):
67
file('myfile', 'wb').write('hello')
69
self.runbzr('commit -m hello')
70
self.runbzr('branch . my_branch')
71
self.runbzr('fetch-ghosts my_branch')
74
self.runbzr('init source')
75
self.runbzr('checkout --lightweight source checkout')
76
self.runbzr('zap checkout')
77
self.assertIs(False, os.path.exists('checkout'))
78
self.assertIs(True, os.path.exists('source'))
80
def test_zap_branch(self):
81
self.runbzr('init source')
82
self.runbzr('checkout --lightweight source checkout')
83
self.runbzr('zap --branch checkout')
84
self.assertIs(False, os.path.exists('checkout'))
85
self.assertIs(False, os.path.exists('source'))
87
def test_branches(self):
88
self.runbzr('init source')
89
self.runbzr('init source/subsource')
90
self.runbzr('checkout --lightweight source checkout')
91
self.runbzr('init checkout/subcheckout')
92
self.runbzr('init checkout/.bzr/subcheckout')
93
out = self.capture('branches')
94
lines = out.split('\n')
95
self.assertIs(True, 'source' in lines)
96
self.assertIs(True, 'source/subsource' in lines)
97
self.assertIs(True, 'checkout/subcheckout' in lines)
98
self.assertIs(True, 'checkout' not in lines)
99
self.assertIs(True, 'checkout/.bzr/subcheckout' not in lines)
102
return makeSuite(TestBzrTools)