111
111
# Make sure the exported directory contains 'a', but does not contain
113
113
self.assertEqual(['a'], files)
115
def example_branch(self):
116
tree = self.make_branch_and_tree('branch')
117
f = open('branch/hello', 'wb')
125
f = open('branch/goodbye', 'wb')
134
def test_basic_directory_export(self):
135
self.example_branch()
139
self.run_bzr('export', '../latest')
140
self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('../latest')))
141
self.check_file_contents('../latest/goodbye', 'baz')
142
self.run_bzr('export', '../first', '-r', '1')
143
self.assertEqual(['hello'], sorted(os.listdir('../first')))
144
self.check_file_contents('../first/hello', 'foo')
146
# Even with .gz and .bz2 it is still a directory
147
self.run_bzr('export', '../first.gz', '-r', '1')
148
self.check_file_contents('../first.gz/hello', 'foo')
149
self.run_bzr('export', '../first.bz2', '-r', '1')
150
self.check_file_contents('../first.bz2/hello', 'foo')
152
def test_basic_tarfile_export(self):
153
self.example_branch()
156
self.run_bzr('export', '../first.tar', '-r', '1')
157
self.failUnless(os.path.isfile('../first.tar'))
158
tf = tarfile.open('../first.tar')
160
self.assertEqual(['first/hello'], sorted(tf.getnames()))
161
self.assertEqual('foo', tf.extractfile('first/hello').read())
165
self.run_bzr('export', '../first.tar.gz', '-r', '1')
166
self.failUnless(os.path.isfile('../first.tar.gz'))
167
self.run_bzr('export', '../first.tbz2', '-r', '1')
168
self.failUnless(os.path.isfile('../first.tbz2'))
169
self.run_bzr('export', '../first.tar.bz2', '-r', '1')
170
self.failUnless(os.path.isfile('../first.tar.bz2'))
171
self.run_bzr('export', '../first.tar.tbz2', '-r', '1')
172
self.failUnless(os.path.isfile('../first.tar.tbz2'))
174
tf = tarfile.open('../first.tar.tbz2', 'r:bz2')
176
self.assertEqual(['first.tar/hello'], sorted(tf.getnames()))
177
self.assertEqual('foo', tf.extractfile('first.tar/hello').read())
180
self.run_bzr('export', '../first2.tar', '-r', '1', '--root', 'pizza')
181
tf = tarfile.open('../first2.tar')
183
self.assertEqual(['pizza/hello'], sorted(tf.getnames()))
184
self.assertEqual('foo', tf.extractfile('pizza/hello').read())
188
def test_basic_zipfile_export(self):
189
self.example_branch()
192
self.run_bzr('export', '../first.zip', '-r', '1')
193
self.failUnlessExists('../first.zip')
194
zf = zipfile.ZipFile('../first.zip')
196
self.assertEqual(['first/hello'], sorted(zf.namelist()))
197
self.assertEqual('foo', zf.read('first/hello'))
201
self.run_bzr('export', '../first2.zip', '-r', '1', '--root', 'pizza')
202
zf = zipfile.ZipFile('../first2.zip')
204
self.assertEqual(['pizza/hello'], sorted(zf.namelist()))
205
self.assertEqual('foo', zf.read('pizza/hello'))
209
self.run_bzr('export', '../first-zip', '--format=zip', '-r', '1')
210
zf = zipfile.ZipFile('../first-zip')
212
self.assertEqual(['first-zip/hello'], sorted(zf.namelist()))
213
self.assertEqual('foo', zf.read('first-zip/hello'))