/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
4763.2.4 by John Arbash Meinel
merge bzr.2.1 in preparation for NEWS entry.
1
# Copyright (C) 2005-2010 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
1185.61.1 by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
7
#
1185.61.1 by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
12
#
1185.61.1 by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1185.61.1 by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported
16
17
18
"""Black-box tests for bzr export.
19
"""
20
3408.7.1 by Martin Pool
Support tarball export to stdout
21
from StringIO import StringIO
1185.61.1 by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported
22
import os
2024.2.7 by John Arbash Meinel
Set the external_attr bits so Windows respects our directories
23
import stat
2024.2.6 by John Arbash Meinel
In zip files, directories must have trailing slashes
24
import sys
2024.2.1 by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile
25
import tarfile
26
import zipfile
1185.61.1 by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported
27
4241.9.1 by Vincent Ladeuil
Fix test_tar_export erroring test.
28
29
from bzrlib import (
30
    export,
31
    tests,
2024.2.7 by John Arbash Meinel
Set the external_attr bits so Windows respects our directories
32
    )
5283.4.5 by Martin Pool
Update remaining subclasses of ExternalBase
33
from bzrlib.tests import TestCaseWithTransport
34
35
36
class TestExport(TestCaseWithTransport):
1185.61.1 by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported
37
38
    def test_tar_export(self):
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
39
        tree = self.make_branch_and_tree('tar')
40
        self.build_tree(['tar/a'])
41
        tree.add('a')
3577.3.1 by Ian Clatworthy
do not export .bzrrules
42
        self.build_tree_contents([('tar/.bzrrules', '')])
43
        tree.add('.bzrrules')
3577.3.2 by Ian Clatworthy
tweaks following jam's review
44
        self.build_tree(['tar/.bzr-adir/', 'tar/.bzr-adir/afile'])
45
        tree.add(['.bzr-adir/', '.bzr-adir/afile'])
1185.61.1 by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported
46
47
        os.chdir('tar')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
48
        self.run_bzr('ignore something')
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
49
        tree.commit('1')
1185.61.1 by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported
50
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
51
        self.failUnless(tree.has_filename('.bzrignore'))
3577.3.1 by Ian Clatworthy
do not export .bzrrules
52
        self.failUnless(tree.has_filename('.bzrrules'))
3577.3.2 by Ian Clatworthy
tweaks following jam's review
53
        self.failUnless(tree.has_filename('.bzr-adir'))
54
        self.failUnless(tree.has_filename('.bzr-adir/afile'))
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
55
        self.run_bzr('export test.tar.gz')
1185.61.1 by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported
56
        ball = tarfile.open('test.tar.gz')
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
57
        # Make sure the tarball contains 'a', but does not contain
58
        # '.bzrignore'.
59
        self.assertEqual(['test/a'], sorted(ball.getnames()))
2024.2.1 by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile
60
3638.3.9 by Vincent Ladeuil
Fix tar-related failing test (python-2.5.1 bug).
61
        if sys.version_info < (2, 5, 2) and sys.platform == 'darwin':
62
            raise tests.KnownFailure('python %r has a tar related bug, upgrade'
4398.2.1 by jszakmeister
Wrap the argument to the KnownFailure string as a tuple to keep from getting an error about not consuming all the arguments.
63
                                     % (sys.version_info,))
3408.7.1 by Martin Pool
Support tarball export to stdout
64
        out, err = self.run_bzr('export --format=tgz --root=test -')
65
        ball = tarfile.open('', fileobj=StringIO(out))
66
        self.assertEqual(['test/a'], sorted(ball.getnames()))
67
2024.2.1 by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile
68
    def test_tar_export_unicode(self):
5050.37.1 by Andrew Bennetts
Some fixes for tests that did not cope with LANG=C.
69
        self.requireFeature(tests.UnicodeFilenameFeature)
2024.2.1 by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile
70
        tree = self.make_branch_and_tree('tar')
4241.9.5 by Vincent Ladeuil
Fix unicode related OSX failures.
71
        # FIXME: using fname = u'\xe5.txt' below triggers a bug revealed since
72
        # bzr.dev revno 4216 but more related to OSX/working trees/unicode than
4241.9.6 by Vincent Ladeuil
Add NEWS entry.
73
        # export itself --vila 20090406
4241.9.5 by Vincent Ladeuil
Fix unicode related OSX failures.
74
        fname = u'\N{Euro Sign}.txt'
5050.37.1 by Andrew Bennetts
Some fixes for tests that did not cope with LANG=C.
75
        self.build_tree(['tar/' + fname])
2024.2.1 by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile
76
        tree.add([fname])
77
        tree.commit('first')
78
79
        os.chdir('tar')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
80
        self.run_bzr('export test.tar')
2024.2.1 by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile
81
        ball = tarfile.open('test.tar')
82
        # all paths are prefixed with the base name of the tarball
83
        self.assertEqual(['test/' + fname.encode('utf8')],
84
                         sorted(ball.getnames()))
1185.61.1 by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported
85
5152.1.1 by Parth Malwankar
Fixed bug #413406. unicode names for parent directory
86
    def test_tar_export_unicode_basedir(self):
87
        """Test for bug #413406"""
5050.37.1 by Andrew Bennetts
Some fixes for tests that did not cope with LANG=C.
88
        self.requireFeature(tests.UnicodeFilenameFeature)
5152.1.1 by Parth Malwankar
Fixed bug #413406. unicode names for parent directory
89
        basedir = u'\N{euro sign}'
90
        os.mkdir(basedir)
91
        os.chdir(basedir)
92
        self.run_bzr(['init', 'branch'])
93
        os.chdir('branch')
94
        self.run_bzr(['export', '--format', 'tgz', u'test.tar.gz'])
95
1185.61.1 by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported
96
    def test_zip_export(self):
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
97
        tree = self.make_branch_and_tree('zip')
98
        self.build_tree(['zip/a'])
99
        tree.add('a')
3577.3.1 by Ian Clatworthy
do not export .bzrrules
100
        self.build_tree_contents([('zip/.bzrrules', '')])
101
        tree.add('.bzrrules')
3577.3.2 by Ian Clatworthy
tweaks following jam's review
102
        self.build_tree(['zip/.bzr-adir/', 'zip/.bzr-adir/afile'])
103
        tree.add(['.bzr-adir/', '.bzr-adir/afile'])
1185.61.1 by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported
104
105
        os.chdir('zip')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
106
        self.run_bzr('ignore something')
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
107
        tree.commit('1')
108
109
        self.failUnless(tree.has_filename('.bzrignore'))
3577.3.1 by Ian Clatworthy
do not export .bzrrules
110
        self.failUnless(tree.has_filename('.bzrrules'))
3577.3.2 by Ian Clatworthy
tweaks following jam's review
111
        self.failUnless(tree.has_filename('.bzr-adir'))
112
        self.failUnless(tree.has_filename('.bzr-adir/afile'))
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
113
        self.run_bzr('export test.zip')
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
114
115
        zfile = zipfile.ZipFile('test.zip')
116
        # Make sure the zipfile contains 'a', but does not contain
117
        # '.bzrignore'.
118
        self.assertEqual(['test/a'], sorted(zfile.namelist()))
2024.2.1 by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile
119
120
    def test_zip_export_unicode(self):
5050.37.1 by Andrew Bennetts
Some fixes for tests that did not cope with LANG=C.
121
        self.requireFeature(tests.UnicodeFilenameFeature)
2024.2.1 by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile
122
        tree = self.make_branch_and_tree('zip')
4241.9.5 by Vincent Ladeuil
Fix unicode related OSX failures.
123
        fname = u'\N{Euro Sign}.txt'
5050.37.1 by Andrew Bennetts
Some fixes for tests that did not cope with LANG=C.
124
        self.build_tree(['zip/' + fname])
2024.2.1 by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile
125
        tree.add([fname])
126
        tree.commit('first')
127
128
        os.chdir('zip')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
129
        self.run_bzr('export test.zip')
2024.2.1 by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile
130
        zfile = zipfile.ZipFile('test.zip')
131
        # all paths are prefixed with the base name of the zipfile
132
        self.assertEqual(['test/' + fname.encode('utf8')],
133
                         sorted(zfile.namelist()))
1185.61.5 by Jamie Wilkinson
add test for directory export
134
2024.2.6 by John Arbash Meinel
In zip files, directories must have trailing slashes
135
    def test_zip_export_directories(self):
136
        tree = self.make_branch_and_tree('zip')
137
        self.build_tree(['zip/a', 'zip/b/', 'zip/b/c', 'zip/d/'])
138
        tree.add(['a', 'b', 'b/c', 'd'])
139
        tree.commit('init')
140
141
        os.chdir('zip')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
142
        self.run_bzr('export test.zip')
2024.2.6 by John Arbash Meinel
In zip files, directories must have trailing slashes
143
        zfile = zipfile.ZipFile('test.zip')
144
        names = sorted(zfile.namelist())
2024.2.7 by John Arbash Meinel
Set the external_attr bits so Windows respects our directories
145
2024.2.8 by John Arbash Meinel
paths are always forward slashed for python zipfiles
146
        # even on win32, zipfile.ZipFile changes all names to use
147
        # forward slashes
148
        self.assertEqual(['test/a', 'test/b/', 'test/b/c', 'test/d/'], names)
2024.2.7 by John Arbash Meinel
Set the external_attr bits so Windows respects our directories
149
4823.1.2 by Ivan Sagalaev
File mode is given a name and gets tested
150
        file_attr = stat.S_IFREG | export.zip_exporter.FILE_PERMISSIONS
5664.2.1 by Jelmer Vernooij
Fix setting of mode on directories in zip files.
151
        dir_attr = (stat.S_IFDIR | export.zip_exporter.ZIP_DIRECTORY_BIT |
152
                    export.zip_exporter.DIR_PERMISSIONS)
2024.2.7 by John Arbash Meinel
Set the external_attr bits so Windows respects our directories
153
154
        a_info = zfile.getinfo(names[0])
155
        self.assertEqual(file_attr, a_info.external_attr)
156
157
        b_info = zfile.getinfo(names[1])
158
        self.assertEqual(dir_attr, b_info.external_attr)
159
160
        c_info = zfile.getinfo(names[2])
161
        self.assertEqual(file_attr, c_info.external_attr)
162
163
        d_info = zfile.getinfo(names[3])
164
        self.assertEqual(dir_attr, d_info.external_attr)
2024.2.6 by John Arbash Meinel
In zip files, directories must have trailing slashes
165
1185.61.5 by Jamie Wilkinson
add test for directory export
166
    def test_dir_export(self):
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
167
        tree = self.make_branch_and_tree('dir')
168
        self.build_tree(['dir/a'])
169
        tree.add('a')
3577.3.1 by Ian Clatworthy
do not export .bzrrules
170
        self.build_tree_contents([('dir/.bzrrules', '')])
171
        tree.add('.bzrrules')
3577.3.2 by Ian Clatworthy
tweaks following jam's review
172
        self.build_tree(['dir/.bzr-adir/', 'dir/.bzr-adir/afile'])
173
        tree.add(['.bzr-adir/', '.bzr-adir/afile'])
1185.61.5 by Jamie Wilkinson
add test for directory export
174
175
        os.chdir('dir')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
176
        self.run_bzr('ignore something')
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
177
        tree.commit('1')
1185.61.5 by Jamie Wilkinson
add test for directory export
178
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
179
        self.failUnless(tree.has_filename('.bzrignore'))
3577.3.1 by Ian Clatworthy
do not export .bzrrules
180
        self.failUnless(tree.has_filename('.bzrrules'))
3577.3.2 by Ian Clatworthy
tweaks following jam's review
181
        self.failUnless(tree.has_filename('.bzr-adir'))
182
        self.failUnless(tree.has_filename('.bzr-adir/afile'))
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
183
        self.run_bzr('export direxport')
1185.61.5 by Jamie Wilkinson
add test for directory export
184
185
        files = sorted(os.listdir('direxport'))
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
186
        # Make sure the exported directory contains 'a', but does not contain
187
        # '.bzrignore'.
188
        self.assertEqual(['a'], files)
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
189
190
    def example_branch(self):
3613.2.1 by Robert Collins
Teach export how to export a subdirectory. (Robert Collins)
191
        """Create a branch a 'branch' containing hello and goodbye."""
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
192
        tree = self.make_branch_and_tree('branch')
2024.2.4 by John Arbash Meinel
Use build_tree_contents instead of manually opening the file
193
        self.build_tree_contents([('branch/hello', 'foo')])
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
194
        tree.add('hello')
195
        tree.commit('setup')
196
2024.2.4 by John Arbash Meinel
Use build_tree_contents instead of manually opening the file
197
        self.build_tree_contents([('branch/goodbye', 'baz')])
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
198
        tree.add('goodbye')
199
        tree.commit('setup')
200
        return tree
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
201
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
202
    def test_basic_directory_export(self):
203
        self.example_branch()
204
        os.chdir('branch')
205
206
        # Directory exports
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
207
        self.run_bzr('export ../latest')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
208
        self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('../latest')))
209
        self.check_file_contents('../latest/goodbye', 'baz')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
210
        self.run_bzr('export ../first -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
211
        self.assertEqual(['hello'], sorted(os.listdir('../first')))
212
        self.check_file_contents('../first/hello', 'foo')
213
214
        # Even with .gz and .bz2 it is still a directory
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
215
        self.run_bzr('export ../first.gz -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
216
        self.check_file_contents('../first.gz/hello', 'foo')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
217
        self.run_bzr('export ../first.bz2 -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
218
        self.check_file_contents('../first.bz2/hello', 'foo')
219
220
    def test_basic_tarfile_export(self):
221
        self.example_branch()
222
        os.chdir('branch')
223
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
224
        self.run_bzr('export ../first.tar -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
225
        self.failUnless(os.path.isfile('../first.tar'))
226
        tf = tarfile.open('../first.tar')
227
        try:
228
            self.assertEqual(['first/hello'], sorted(tf.getnames()))
229
            self.assertEqual('foo', tf.extractfile('first/hello').read())
230
        finally:
231
            tf.close()
232
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
233
        self.run_bzr('export ../first.tar.gz -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
234
        self.failUnless(os.path.isfile('../first.tar.gz'))
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
235
        self.run_bzr('export ../first.tbz2 -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
236
        self.failUnless(os.path.isfile('../first.tbz2'))
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
237
        self.run_bzr('export ../first.tar.bz2 -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
238
        self.failUnless(os.path.isfile('../first.tar.bz2'))
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
239
        self.run_bzr('export ../first.tar.tbz2 -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
240
        self.failUnless(os.path.isfile('../first.tar.tbz2'))
241
242
        tf = tarfile.open('../first.tar.tbz2', 'r:bz2')
243
        try:
244
            self.assertEqual(['first.tar/hello'], sorted(tf.getnames()))
245
            self.assertEqual('foo', tf.extractfile('first.tar/hello').read())
246
        finally:
247
            tf.close()
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
248
        self.run_bzr('export ../first2.tar -r 1 --root pizza')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
249
        tf = tarfile.open('../first2.tar')
250
        try:
251
            self.assertEqual(['pizza/hello'], sorted(tf.getnames()))
252
            self.assertEqual('foo', tf.extractfile('pizza/hello').read())
253
        finally:
254
            tf.close()
255
256
    def test_basic_zipfile_export(self):
257
        self.example_branch()
258
        os.chdir('branch')
259
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
260
        self.run_bzr('export ../first.zip -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
261
        self.failUnlessExists('../first.zip')
262
        zf = zipfile.ZipFile('../first.zip')
263
        try:
264
            self.assertEqual(['first/hello'], sorted(zf.namelist()))
265
            self.assertEqual('foo', zf.read('first/hello'))
266
        finally:
267
            zf.close()
268
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
269
        self.run_bzr('export ../first2.zip -r 1 --root pizza')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
270
        zf = zipfile.ZipFile('../first2.zip')
271
        try:
272
            self.assertEqual(['pizza/hello'], sorted(zf.namelist()))
273
            self.assertEqual('foo', zf.read('pizza/hello'))
274
        finally:
275
            zf.close()
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
276
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
277
        self.run_bzr('export ../first-zip --format=zip -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
278
        zf = zipfile.ZipFile('../first-zip')
279
        try:
280
            self.assertEqual(['first-zip/hello'], sorted(zf.namelist()))
281
            self.assertEqual('foo', zf.read('first-zip/hello'))
282
        finally:
283
            zf.close()
284
2099.1.1 by Daniel Silverstone
Add source branch support to export command
285
    def test_export_from_outside_branch(self):
286
        self.example_branch()
287
288
        # Use directory exports to test stating the branch location
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
289
        self.run_bzr('export latest branch')
2099.1.1 by Daniel Silverstone
Add source branch support to export command
290
        self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('latest')))
291
        self.check_file_contents('latest/goodbye', 'baz')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
292
        self.run_bzr('export first -r 1 branch')
2099.1.1 by Daniel Silverstone
Add source branch support to export command
293
        self.assertEqual(['hello'], sorted(os.listdir('first')))
294
        self.check_file_contents('first/hello', 'foo')
3613.2.1 by Robert Collins
Teach export how to export a subdirectory. (Robert Collins)
295
296
    def test_export_partial_tree(self):
297
        tree = self.example_branch()
298
        self.build_tree(['branch/subdir/', 'branch/subdir/foo.txt'])
299
        tree.smart_add(['branch'])
300
        tree.commit('more setup')
301
        out, err = self.run_bzr('export exported branch/subdir')
302
        self.assertEqual(['foo.txt'], os.listdir('exported'))
5076.2.2 by Jelmer Vernooij
``bzr export`` now takes an optional argument ``--use-tree-timestamp``
303
5076.2.3 by Jelmer Vernooij
Review comments from Rob.
304
    def test_dir_export_per_file_timestamps(self):
5076.2.2 by Jelmer Vernooij
``bzr export`` now takes an optional argument ``--use-tree-timestamp``
305
        tree = self.example_branch()
306
        self.build_tree_contents([('branch/har', 'foo')])
307
        tree.add('har')
5151.3.1 by Martin
Fix os.utime test failures, three on FAT filesystems and one with readonly files
308
        # Earliest allowable date on FAT32 filesystems is 1980-01-01
309
        tree.commit('setup', timestamp=315532800)
5076.2.3 by Jelmer Vernooij
Review comments from Rob.
310
        self.run_bzr('export --per-file-timestamps t branch')
5076.2.2 by Jelmer Vernooij
``bzr export`` now takes an optional argument ``--use-tree-timestamp``
311
        har_st = os.stat('t/har')
5151.3.1 by Martin
Fix os.utime test failures, three on FAT filesystems and one with readonly files
312
        self.assertEquals(315532800, har_st.st_mtime)
5076.2.2 by Jelmer Vernooij
``bzr export`` now takes an optional argument ``--use-tree-timestamp``
313
5171.3.7 by Martin von Gagern
Added blackbox tests for --directory option.
314
    def test_export_directory(self):
315
        """Test --directory option"""
316
        self.example_branch()
317
        self.run_bzr(['export', '--directory=branch', 'latest'])
318
        self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('latest')))
319
        self.check_file_contents('latest/goodbye', 'baz')