/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
4241.9.1 by Vincent Ladeuil
Fix test_tar_export erroring test.
151
        dir_attr = stat.S_IFDIR | export.zip_exporter.ZIP_DIRECTORY_BIT
2024.2.7 by John Arbash Meinel
Set the external_attr bits so Windows respects our directories
152
153
        a_info = zfile.getinfo(names[0])
154
        self.assertEqual(file_attr, a_info.external_attr)
155
156
        b_info = zfile.getinfo(names[1])
157
        self.assertEqual(dir_attr, b_info.external_attr)
158
159
        c_info = zfile.getinfo(names[2])
160
        self.assertEqual(file_attr, c_info.external_attr)
161
162
        d_info = zfile.getinfo(names[3])
163
        self.assertEqual(dir_attr, d_info.external_attr)
2024.2.6 by John Arbash Meinel
In zip files, directories must have trailing slashes
164
1185.61.5 by Jamie Wilkinson
add test for directory export
165
    def test_dir_export(self):
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
166
        tree = self.make_branch_and_tree('dir')
167
        self.build_tree(['dir/a'])
168
        tree.add('a')
3577.3.1 by Ian Clatworthy
do not export .bzrrules
169
        self.build_tree_contents([('dir/.bzrrules', '')])
170
        tree.add('.bzrrules')
3577.3.2 by Ian Clatworthy
tweaks following jam's review
171
        self.build_tree(['dir/.bzr-adir/', 'dir/.bzr-adir/afile'])
172
        tree.add(['.bzr-adir/', '.bzr-adir/afile'])
1185.61.5 by Jamie Wilkinson
add test for directory export
173
174
        os.chdir('dir')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
175
        self.run_bzr('ignore something')
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
176
        tree.commit('1')
1185.61.5 by Jamie Wilkinson
add test for directory export
177
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
178
        self.failUnless(tree.has_filename('.bzrignore'))
3577.3.1 by Ian Clatworthy
do not export .bzrrules
179
        self.failUnless(tree.has_filename('.bzrrules'))
3577.3.2 by Ian Clatworthy
tweaks following jam's review
180
        self.failUnless(tree.has_filename('.bzr-adir'))
181
        self.failUnless(tree.has_filename('.bzr-adir/afile'))
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
182
        self.run_bzr('export direxport')
1185.61.5 by Jamie Wilkinson
add test for directory export
183
184
        files = sorted(os.listdir('direxport'))
2024.2.2 by John Arbash Meinel
Cleanup the export tests to act more like the current api.
185
        # Make sure the exported directory contains 'a', but does not contain
186
        # '.bzrignore'.
187
        self.assertEqual(['a'], files)
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
188
189
    def example_branch(self):
3613.2.1 by Robert Collins
Teach export how to export a subdirectory. (Robert Collins)
190
        """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
191
        tree = self.make_branch_and_tree('branch')
2024.2.4 by John Arbash Meinel
Use build_tree_contents instead of manually opening the file
192
        self.build_tree_contents([('branch/hello', 'foo')])
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
193
        tree.add('hello')
194
        tree.commit('setup')
195
2024.2.4 by John Arbash Meinel
Use build_tree_contents instead of manually opening the file
196
        self.build_tree_contents([('branch/goodbye', 'baz')])
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
197
        tree.add('goodbye')
198
        tree.commit('setup')
199
        return tree
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
200
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
201
    def test_basic_directory_export(self):
202
        self.example_branch()
203
        os.chdir('branch')
204
205
        # Directory exports
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
206
        self.run_bzr('export ../latest')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
207
        self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('../latest')))
208
        self.check_file_contents('../latest/goodbye', 'baz')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
209
        self.run_bzr('export ../first -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
210
        self.assertEqual(['hello'], sorted(os.listdir('../first')))
211
        self.check_file_contents('../first/hello', 'foo')
212
213
        # Even with .gz and .bz2 it is still a directory
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
214
        self.run_bzr('export ../first.gz -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
215
        self.check_file_contents('../first.gz/hello', 'foo')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
216
        self.run_bzr('export ../first.bz2 -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
217
        self.check_file_contents('../first.bz2/hello', 'foo')
218
219
    def test_basic_tarfile_export(self):
220
        self.example_branch()
221
        os.chdir('branch')
222
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
223
        self.run_bzr('export ../first.tar -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
224
        self.failUnless(os.path.isfile('../first.tar'))
225
        tf = tarfile.open('../first.tar')
226
        try:
227
            self.assertEqual(['first/hello'], sorted(tf.getnames()))
228
            self.assertEqual('foo', tf.extractfile('first/hello').read())
229
        finally:
230
            tf.close()
231
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
232
        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
233
        self.failUnless(os.path.isfile('../first.tar.gz'))
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
234
        self.run_bzr('export ../first.tbz2 -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
235
        self.failUnless(os.path.isfile('../first.tbz2'))
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
236
        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
237
        self.failUnless(os.path.isfile('../first.tar.bz2'))
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
238
        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
239
        self.failUnless(os.path.isfile('../first.tar.tbz2'))
240
241
        tf = tarfile.open('../first.tar.tbz2', 'r:bz2')
242
        try:
243
            self.assertEqual(['first.tar/hello'], sorted(tf.getnames()))
244
            self.assertEqual('foo', tf.extractfile('first.tar/hello').read())
245
        finally:
246
            tf.close()
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
247
        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
248
        tf = tarfile.open('../first2.tar')
249
        try:
250
            self.assertEqual(['pizza/hello'], sorted(tf.getnames()))
251
            self.assertEqual('foo', tf.extractfile('pizza/hello').read())
252
        finally:
253
            tf.close()
254
255
    def test_basic_zipfile_export(self):
256
        self.example_branch()
257
        os.chdir('branch')
258
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
259
        self.run_bzr('export ../first.zip -r 1')
2024.2.3 by John Arbash Meinel
Move out export tests from test_too_much, refactor
260
        self.failUnlessExists('../first.zip')
261
        zf = zipfile.ZipFile('../first.zip')
262
        try:
263
            self.assertEqual(['first/hello'], sorted(zf.namelist()))
264
            self.assertEqual('foo', zf.read('first/hello'))
265
        finally:
266
            zf.close()
267
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
268
        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
269
        zf = zipfile.ZipFile('../first2.zip')
270
        try:
271
            self.assertEqual(['pizza/hello'], sorted(zf.namelist()))
272
            self.assertEqual('foo', zf.read('pizza/hello'))
273
        finally:
274
            zf.close()
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
275
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
276
        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
277
        zf = zipfile.ZipFile('../first-zip')
278
        try:
279
            self.assertEqual(['first-zip/hello'], sorted(zf.namelist()))
280
            self.assertEqual('foo', zf.read('first-zip/hello'))
281
        finally:
282
            zf.close()
283
2099.1.1 by Daniel Silverstone
Add source branch support to export command
284
    def test_export_from_outside_branch(self):
285
        self.example_branch()
286
287
        # Use directory exports to test stating the branch location
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
288
        self.run_bzr('export latest branch')
2099.1.1 by Daniel Silverstone
Add source branch support to export command
289
        self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('latest')))
290
        self.check_file_contents('latest/goodbye', 'baz')
2552.2.3 by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests.
291
        self.run_bzr('export first -r 1 branch')
2099.1.1 by Daniel Silverstone
Add source branch support to export command
292
        self.assertEqual(['hello'], sorted(os.listdir('first')))
293
        self.check_file_contents('first/hello', 'foo')
3613.2.1 by Robert Collins
Teach export how to export a subdirectory. (Robert Collins)
294
295
    def test_export_partial_tree(self):
296
        tree = self.example_branch()
297
        self.build_tree(['branch/subdir/', 'branch/subdir/foo.txt'])
298
        tree.smart_add(['branch'])
299
        tree.commit('more setup')
300
        out, err = self.run_bzr('export exported branch/subdir')
301
        self.assertEqual(['foo.txt'], os.listdir('exported'))
5076.2.2 by Jelmer Vernooij
``bzr export`` now takes an optional argument ``--use-tree-timestamp``
302
5076.2.3 by Jelmer Vernooij
Review comments from Rob.
303
    def test_dir_export_per_file_timestamps(self):
5076.2.2 by Jelmer Vernooij
``bzr export`` now takes an optional argument ``--use-tree-timestamp``
304
        tree = self.example_branch()
305
        self.build_tree_contents([('branch/har', 'foo')])
306
        tree.add('har')
5151.3.1 by Martin
Fix os.utime test failures, three on FAT filesystems and one with readonly files
307
        # Earliest allowable date on FAT32 filesystems is 1980-01-01
308
        tree.commit('setup', timestamp=315532800)
5076.2.3 by Jelmer Vernooij
Review comments from Rob.
309
        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``
310
        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
311
        self.assertEquals(315532800, har_st.st_mtime)
5076.2.2 by Jelmer Vernooij
``bzr export`` now takes an optional argument ``--use-tree-timestamp``
312
5171.3.7 by Martin von Gagern
Added blackbox tests for --directory option.
313
    def test_export_directory(self):
314
        """Test --directory option"""
315
        self.example_branch()
316
        self.run_bzr(['export', '--directory=branch', 'latest'])
317
        self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('latest')))
318
        self.check_file_contents('latest/goodbye', 'baz')