147
147
test.runbzr('add goodbye')
148
148
test.runbzr('commit -m setup goodbye')
150
def test_export(self):
153
self.example_branch()
154
self.runbzr('export ../latest')
155
self.assertEqual(file('../latest/goodbye', 'rt').read(), 'baz')
156
self.runbzr('export ../first -r 1')
157
self.assert_(not os.path.exists('../first/goodbye'))
158
self.assertEqual(file('../first/hello', 'rt').read(), 'foo')
159
self.runbzr('export ../first.gz -r 1')
160
self.assertEqual(file('../first.gz/hello', 'rt').read(), 'foo')
161
self.runbzr('export ../first.bz2 -r 1')
162
self.assertEqual(file('../first.bz2/hello', 'rt').read(), 'foo')
164
from tarfile import TarFile
165
self.runbzr('export ../first.tar -r 1')
166
self.assert_(os.path.isfile('../first.tar'))
167
tf = TarFile('../first.tar')
168
self.assert_('first/hello' in tf.getnames(), tf.getnames())
169
self.assertEqual(tf.extractfile('first/hello').read(), 'foo')
170
self.runbzr('export ../first.tar.gz -r 1')
171
self.assert_(os.path.isfile('../first.tar.gz'))
172
self.runbzr('export ../first.tbz2 -r 1')
173
self.assert_(os.path.isfile('../first.tbz2'))
174
self.runbzr('export ../first.tar.bz2 -r 1')
175
self.assert_(os.path.isfile('../first.tar.bz2'))
176
self.runbzr('export ../first.tar.tbz2 -r 1')
177
self.assert_(os.path.isfile('../first.tar.tbz2'))
179
from bz2 import BZ2File
180
tf = TarFile('../first.tar.tbz2',
181
fileobj=BZ2File('../first.tar.tbz2', 'r'))
182
self.assert_('first.tar/hello' in tf.getnames(), tf.getnames())
183
self.assertEqual(tf.extractfile('first.tar/hello').read(), 'foo')
184
self.runbzr('export ../first2.tar -r 1 --root pizza')
185
tf = TarFile('../first2.tar')
186
self.assert_('pizza/hello' in tf.getnames(), tf.getnames())
188
from zipfile import ZipFile
189
self.runbzr('export ../first.zip -r 1')
190
self.failUnlessExists('../first.zip')
191
zf = ZipFile('../first.zip')
192
self.assert_('first/hello' in zf.namelist(), zf.namelist())
193
self.assertEqual(zf.read('first/hello'), 'foo')
195
self.runbzr('export ../first2.zip -r 1 --root pizza')
196
zf = ZipFile('../first2.zip')
197
self.assert_('pizza/hello' in zf.namelist(), zf.namelist())
199
self.runbzr('export ../first-zip --format=zip -r 1')
200
zf = ZipFile('../first-zip')
201
self.assert_('first-zip/hello' in zf.namelist(), zf.namelist())
203
def test_inventory(self):
205
def output_equals(value, *args):
206
out = self.runbzr(['inventory'] + list(args), backtick=True)
207
self.assertEquals(out, value)
210
open('a', 'wb').write('hello\n')
216
output_equals('a\n', '--kind', 'file')
217
output_equals('b\n', '--kind', 'directory')
219
150
def test_pull_verbose(self):
220
151
"""Pull changes from one branch to another and watch the output."""