5
5
from bzrlib import branch, osutils, workingtree
6
6
from bzrlib.config import LocationConfig
7
7
from bzrlib.transport import get_transport
8
from bzrlib.tests import (
11
from bzrlib.plugins.bzrtools import command
14
from bzrlib.tests.features import (
16
ModuleAvailableFeature,
18
except ImportError: # bzr < 2.5
19
from bzrlib.tests import (
21
ModuleAvailableFeature,
25
LzmaFeature = ModuleAvailableFeature("lzma")
8
from bzrlib.tests import TestCaseWithTransport, HardlinkFeature
28
11
class TestBzrTools(TestCaseWithTransport):
31
TestCaseWithTransport.setUp(self)
32
command._testing = True
33
self.addCleanup(command._stop_testing)
36
13
def touch(filename):
37
14
file(filename, 'wb').write('')
49
26
self.run_bzr('init')
50
27
self.run_bzr('fetch-ghosts .')
52
def test_fetch_ghosts_with_saved(self):
53
wt = self.make_branch_and_tree('.')
54
wt.branch.set_parent('.')
55
self.run_bzr('fetch-ghosts')
57
29
def test_patch(self):
58
30
self.run_bzr('init')
59
31
file('myfile', 'wb').write('hello')
104
76
checkout.add('file')
105
77
self.run_bzr_error(('This checkout has uncommitted changes',),
107
self.assertPathExists('checkout')
79
self.failUnlessExists('checkout')
108
80
self.run_bzr('zap checkout --force')
109
self.assertPathDoesNotExist('checkout')
110
self.assertPathExists('source')
81
self.failIfExists('checkout')
82
self.failUnlessExists('source')
112
84
def test_zap_branch(self):
113
85
self.run_bzr('init source')
121
93
self.assertIs(False, os.path.exists('checkout2'))
122
94
self.assertIs(False, os.path.exists('source2'))
124
def test_list_branches(self):
96
def test_branches(self):
125
97
self.run_bzr('init source')
126
98
self.run_bzr('init source/subsource')
127
99
self.run_bzr('checkout --lightweight source checkout')
128
100
self.run_bzr('init checkout/subcheckout')
129
101
self.run_bzr('init checkout/.bzr/subcheckout')
130
out = self.run_bzr('list-branches')[0]
102
out = self.run_bzr('branches')[0]
131
103
lines = out.split('\n')
132
104
self.assertIs(True, 'source' in lines)
133
105
self.assertIs(True, 'source/subsource' in lines)
149
121
self.run_bzr('init ../import')
150
122
os.chdir('../import')
151
123
self.run_bzr('import ../source-0.1.tar.gz')
152
self.assertPathExists('src/myfile')
124
self.failUnlessExists('src/myfile')
153
125
result = self.run_bzr('import ../source-0.1.tar.gz', retcode=3)[1]
154
126
self.assertContainsRe(result, 'Working tree has uncommitted changes')
155
127
self.run_bzr('commit -m commit')
158
130
self.run_bzr('init import2')
159
131
self.run_bzr('import source-0.1.tar.gz import2')
160
self.assertPathExists('import2/src/myfile')
132
self.failUnlessExists('import2/src/myfile')
161
133
self.run_bzr('import source-0.1.tar.gz import3')
162
self.assertPathExists('import3/src/myfile')
134
self.failUnlessExists('import3/src/myfile')
163
135
self.run_bzr('import source-0.1.tar.bz2 import4')
164
self.assertPathExists('import4/src/myfile')
136
self.failUnlessExists('import4/src/myfile')
165
137
self.run_bzr('import source-0.1 import5')
166
self.assertPathExists('import5/src/myfile')
168
def test_import_upstream_lzma(self):
169
self.requireFeature(LzmaFeature)
170
self.run_bzr('init source')
171
os.mkdir('source/src')
172
f = file('source/src/myfile', 'wb')
177
self.run_bzr('commit -m hello')
178
self.run_bzr('export ../source-0.1.tar.lzma')
179
self.run_bzr('export ../source-0.1.tar.xz')
181
self.run_bzr('import source-0.1.tar.lzma import1')
182
self.assertPathExists('import1/src/myfile')
183
self.run_bzr('import source-0.1.tar.xz import2')
184
self.assertPathExists('import2/src/myfile')
138
self.failUnlessExists('import5/src/myfile')
186
140
def test_cbranch(self):
187
141
source = self.make_branch_and_tree('source')
199
153
def test_cbranch_hardlink(self):
200
154
self.requireFeature(HardlinkFeature)
201
# Later formats don't support hardlinks. Boo!
202
source = self.make_branch_and_tree('source', format='1.9')
155
source = self.make_branch_and_tree('source')
203
156
self.build_tree(['source/file'])
204
157
source.add('file')
205
158
source.commit('added file')