bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2005-2011, 2016 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 |
||
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
18 |
"""Black-box tests for brz export.
|
|
1185.61.1
by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported |
19 |
"""
|
20 |
||
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
21 |
from io import BytesIO |
|
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.1
by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile |
24 |
import tarfile |
|
5718.5.26
by Jelmer Vernooij
Work around zip info time zone issues. |
25 |
import time |
|
2024.2.1
by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile |
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 |
|
|
6968.2.7
by Jelmer Vernooij
Add breezy.archive. |
29 |
from ...archive import zip |
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
30 |
from ... import ( |
|
4241.9.1
by Vincent Ladeuil
Fix test_tar_export erroring test. |
31 |
export, |
|
7045.4.7
by Jelmer Vernooij
Fix remaining tests. |
32 |
osutils, |
|
2024.2.7
by John Arbash Meinel
Set the external_attr bits so Windows respects our directories |
33 |
)
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
34 |
from .. import ( |
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
35 |
features, |
36 |
TestCaseWithTransport, |
|
37 |
)
|
|
|
5283.4.5
by Martin Pool
Update remaining subclasses of ExternalBase |
38 |
|
39 |
||
40 |
class TestExport(TestCaseWithTransport): |
|
|
1185.61.1
by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported |
41 |
|
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
42 |
# On Windows, if we fail to set the binary bit, and a '\r' or '\n'
|
43 |
# ends up in the data stream, we will get corruption. Add a fair amount
|
|
44 |
# of random data, to help ensure there is at least one.
|
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
45 |
_file_content = (b'!\r\n\t\n \r' + |
46 |
b'r29trp9i1r8k0e24c2o7mcx2isrlaw7toh1hv2mtst3o1udkl36v9xn2z8kt\n' |
|
47 |
b'tvjn7e3i9cj1qs1rw9gcye9w72cbdueiufw8nky7bs08lwggir59d62knecp\n' |
|
48 |
b'7s0537r8sg3e8hdnidji49rswo47c3j8190nh8emef2b6j1mf5kdq45nt3f5\n' |
|
49 |
b'1sz9u7fuzrm4w8bebre7p62sh5os2nkj2iiyuk9n0w0pjpdulu9k2aajejah\n' |
|
50 |
b'ini90ny40qzs12ajuy0ua6l178n93lvy2atqngnntsmtlmqx7yhp0q9a1xr4\n' |
|
51 |
b'1n69kgbo6qu9osjpqq83446r00jijtcstzybfqwm1lnt9spnri2j07bt7bbh\n' |
|
52 |
b'rf3ejatdxta83te2s0pt9rc4hidgy3d2pc53p4wscdt2b1dfxdj9utf5m17f\n' |
|
53 |
b'f03oofcau950o090vyx6m72vfkywo7gp3ajzi6uk02dwqwtumq4r44xx6ho7\n' |
|
54 |
b'nhynborjdjep5j53f9548msb7gd3x9a1xveb4s8zfo6cbdw2kdngcrbakwu8\n' |
|
55 |
b'ql5a8l94gplkwr7oypw5nt1gj5i3xwadyjfr3lb61tfkz31ba7uda9knb294\n' |
|
56 |
b'1azhfta0q3ry9x36lxyanvhp0g5z0t5a0i4wnoc8p4htexi915y1cnw4nznn\n' |
|
57 |
b'aj70dvp88ifiblv2bsp98hz570teinj8g472ddxni9ydmazfzwtznbf3hrg6\n' |
|
58 |
b'84gigirjt6n2yagf70036m8d73cz0jpcighpjtxsmbgzbxx7nb4ewq6jbgnc\n' |
|
59 |
b'hux1b0qtsdi0zfhj6g1otf5jcldmtdvuon8y1ttszkqw3ograwi25yl921hy\n' |
|
60 |
b'izgscmfha9xdhxxabs07b40secpw22ah9iwpbmsns6qz0yr6fswto3ft2ez5\n' |
|
61 |
b'ngn48pdfxj1pw246drmj1y2ll5af5w7cz849rapzd9ih7qvalw358co0yzrs\n' |
|
62 |
b'xan9291d1ivjku4o5gjrsnmllrqwxwy86pcivinbmlnzasa9v3o22lgv4uyd\n' |
|
63 |
b'q8kw77bge3hr5rr5kzwjxk223bkmo3z9oju0954undsz8axr3kb3730otrcr\n' |
|
64 |
b'9cwhu37htnizdwxmpoc5qmobycfm7ubbykfumv6zgkl6b8zlslwl7a8b81vz\n' |
|
65 |
b'3weqkvv5csfza9xvwypr6lo0t03fwp0ihmci3m1muh0lf2u30ze0hjag691j\n' |
|
66 |
b'27fjtd3e3zbiin5n2hq21iuo09ukbs73r5rt7vaw6axvoilvdciir9ugjh2c\n' |
|
67 |
b'na2b8dr0ptftoyhyxv1iwg661y338e28fhz4xxwgv3hnoe98ydfa1oou45vj\n' |
|
68 |
b'ln74oac2keqt0agbylrqhfscin7ireae2bql7z2le823ksy47ud57z8ctomp\n' |
|
69 |
b'31s1vwbczdjwqp0o2jc7mkrurvzg8mj2zwcn2iily4gcl4sy4fsh4rignlyz\n') |
|
|
1185.61.1
by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported |
70 |
|
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
71 |
def make_basic_tree(self): |
72 |
tree = self.make_branch_and_tree('tree') |
|
73 |
self.build_tree_contents([('tree/a', self._file_content)]) |
|
74 |
tree.add('a') |
|
|
2024.2.2
by John Arbash Meinel
Cleanup the export tests to act more like the current api. |
75 |
tree.commit('1') |
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
76 |
return tree |
77 |
||
78 |
def make_tree_with_extra_bzr_files(self): |
|
79 |
tree = self.make_basic_tree() |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
80 |
self.build_tree_contents([('tree/.bzrrules', b'')]) |
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
81 |
self.build_tree(['tree/.bzr-adir/', 'tree/.bzr-adir/afile']) |
82 |
tree.add(['.bzrrules', '.bzr-adir/', '.bzr-adir/afile']) |
|
83 |
||
84 |
self.run_bzr('ignore something -d tree') |
|
85 |
tree.commit('2') |
|
86 |
return tree |
|
87 |
||
88 |
def test_tar_export_ignores_bzr(self): |
|
89 |
tree = self.make_tree_with_extra_bzr_files() |
|
|
1185.61.1
by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported |
90 |
|
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
91 |
self.assertTrue(tree.has_filename('.bzrignore')) |
92 |
self.assertTrue(tree.has_filename('.bzrrules')) |
|
93 |
self.assertTrue(tree.has_filename('.bzr-adir')) |
|
94 |
self.assertTrue(tree.has_filename('.bzr-adir/afile')) |
|
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
95 |
self.run_bzr('export test.tar.gz -d tree') |
|
1185.61.1
by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported |
96 |
ball = tarfile.open('test.tar.gz') |
|
2024.2.2
by John Arbash Meinel
Cleanup the export tests to act more like the current api. |
97 |
# Make sure the tarball contains 'a', but does not contain
|
98 |
# '.bzrignore'.
|
|
|
5724.1.2
by John Arbash Meinel
Force test_tar_export to test that it outputs in binary. |
99 |
self.assertEqual(['test/a'], |
100 |
sorted(ball.getnames())) |
|
|
2024.2.1
by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile |
101 |
|
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
102 |
def test_tar_export_unicode_filename(self): |
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
103 |
self.requireFeature(features.UnicodeFilenameFeature) |
|
2024.2.1
by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile |
104 |
tree = self.make_branch_and_tree('tar') |
|
4241.9.5
by Vincent Ladeuil
Fix unicode related OSX failures. |
105 |
# FIXME: using fname = u'\xe5.txt' below triggers a bug revealed since
|
106 |
# bzr.dev revno 4216 but more related to OSX/working trees/unicode than
|
|
|
4241.9.6
by Vincent Ladeuil
Add NEWS entry. |
107 |
# export itself --vila 20090406
|
|
4241.9.5
by Vincent Ladeuil
Fix unicode related OSX failures. |
108 |
fname = u'\N{Euro Sign}.txt' |
|
5050.37.1
by Andrew Bennetts
Some fixes for tests that did not cope with LANG=C. |
109 |
self.build_tree(['tar/' + fname]) |
|
2024.2.1
by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile |
110 |
tree.add([fname]) |
111 |
tree.commit('first') |
|
112 |
||
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
113 |
self.run_bzr('export test.tar -d tar') |
|
2024.2.1
by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile |
114 |
ball = tarfile.open('test.tar') |
115 |
# all paths are prefixed with the base name of the tarball
|
|
|
7045.4.7
by Jelmer Vernooij
Fix remaining tests. |
116 |
self.assertEqual([u'test/' + fname], |
117 |
[osutils.safe_unicode(n) for n in ball.getnames()]) |
|
|
1185.61.1
by Jamie Wilkinson
add blackbox tests for ensuring .bzrignore is not exported |
118 |
|
|
5152.1.1
by Parth Malwankar
Fixed bug #413406. unicode names for parent directory |
119 |
def test_tar_export_unicode_basedir(self): |
120 |
"""Test for bug #413406""" |
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
121 |
self.requireFeature(features.UnicodeFilenameFeature) |
|
5152.1.1
by Parth Malwankar
Fixed bug #413406. unicode names for parent directory |
122 |
basedir = u'\N{euro sign}' |
123 |
os.mkdir(basedir) |
|
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
124 |
self.run_bzr(['init', basedir]) |
125 |
self.run_bzr(['export', '--format', 'tgz', u'test.tar.gz', |
|
126 |
'-d', basedir]) |
|
127 |
||
128 |
def test_zip_export_ignores_bzr(self): |
|
129 |
tree = self.make_tree_with_extra_bzr_files() |
|
|
2024.2.2
by John Arbash Meinel
Cleanup the export tests to act more like the current api. |
130 |
|
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
131 |
self.assertTrue(tree.has_filename('.bzrignore')) |
132 |
self.assertTrue(tree.has_filename('.bzrrules')) |
|
133 |
self.assertTrue(tree.has_filename('.bzr-adir')) |
|
134 |
self.assertTrue(tree.has_filename('.bzr-adir/afile')) |
|
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
135 |
self.run_bzr('export test.zip -d tree') |
|
2024.2.2
by John Arbash Meinel
Cleanup the export tests to act more like the current api. |
136 |
|
137 |
zfile = zipfile.ZipFile('test.zip') |
|
138 |
# Make sure the zipfile contains 'a', but does not contain
|
|
139 |
# '.bzrignore'.
|
|
140 |
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 |
141 |
|
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
142 |
# TODO: This really looks like something that should be using permutation
|
143 |
# testing. Though the actual setup and teardown functions are pretty
|
|
144 |
# different for each
|
|
145 |
def assertZipANameAndContent(self, zfile, root=''): |
|
146 |
"""The file should only contain name 'a' and _file_content""" |
|
147 |
fname = root + 'a' |
|
148 |
self.assertEqual([fname], sorted(zfile.namelist())) |
|
149 |
zfile.testzip() |
|
150 |
self.assertEqualDiff(self._file_content, zfile.read(fname)) |
|
151 |
||
|
5718.5.9
by Jelmer Vernooij
Add test for export zip to stdout. |
152 |
def test_zip_export_stdout(self): |
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
153 |
tree = self.make_basic_tree() |
|
7065.3.6
by Jelmer Vernooij
Fix some more tests. |
154 |
contents = self.run_bzr_raw('export -d tree --format=zip -')[0] |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
155 |
self.assertZipANameAndContent(zipfile.ZipFile(BytesIO(contents))) |
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
156 |
|
157 |
def test_zip_export_file(self): |
|
158 |
tree = self.make_basic_tree() |
|
159 |
self.run_bzr('export -d tree test.zip') |
|
160 |
self.assertZipANameAndContent(zipfile.ZipFile('test.zip'), |
|
161 |
root='test/') |
|
162 |
||
163 |
def assertTarANameAndContent(self, ball, root=''): |
|
164 |
fname = root + 'a' |
|
|
7045.1.10
by Jelmer Vernooij
Fix iterator use in export. |
165 |
ball_iter = iter(ball) |
166 |
tar_info = next(ball_iter) |
|
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
167 |
self.assertEqual(fname, tar_info.name) |
168 |
self.assertEqual(tarfile.REGTYPE, tar_info.type) |
|
169 |
self.assertEqual(len(self._file_content), tar_info.size) |
|
170 |
f = ball.extractfile(tar_info) |
|
171 |
if self._file_content != f.read(): |
|
172 |
self.fail('File content has been corrupted.' |
|
173 |
' Check that all streams are handled in binary mode.') |
|
174 |
# There should be no other files in the tarball
|
|
|
7045.1.10
by Jelmer Vernooij
Fix iterator use in export. |
175 |
self.assertRaises(StopIteration, next, ball_iter) |
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
176 |
|
177 |
def run_tar_export_disk_and_stdout(self, extension, tarfile_flags): |
|
178 |
tree = self.make_basic_tree() |
|
179 |
fname = 'test.%s' % (extension,) |
|
|
5952.1.26
by Vincent Ladeuil
Fix the test failure, streams should be closed. In the right order. |
180 |
self.run_bzr('export -d tree %s' % (fname,)) |
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
181 |
mode = 'r|%s' % (tarfile_flags,) |
182 |
ball = tarfile.open(fname, mode=mode) |
|
183 |
self.assertTarANameAndContent(ball, root='test/') |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
184 |
content = self.run_bzr_raw( |
185 |
'export -d tree --format=%s -' % (extension,))[0] |
|
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
186 |
ball = tarfile.open(mode=mode, fileobj=BytesIO(content)) |
|
5724.1.3
by John Arbash Meinel
Change the exporters to ensure that we are writing the data out in binary mode. |
187 |
self.assertTarANameAndContent(ball, root='') |
188 |
||
189 |
def test_tar_export(self): |
|
190 |
self.run_tar_export_disk_and_stdout('tar', '') |
|
191 |
||
192 |
def test_tgz_export(self): |
|
193 |
self.run_tar_export_disk_and_stdout('tgz', 'gz') |
|
194 |
||
195 |
def test_tbz2_export(self): |
|
196 |
self.run_tar_export_disk_and_stdout('tbz2', 'bz2') |
|
197 |
||
|
2024.2.1
by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile |
198 |
def test_zip_export_unicode(self): |
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
199 |
self.requireFeature(features.UnicodeFilenameFeature) |
|
2024.2.1
by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile |
200 |
tree = self.make_branch_and_tree('zip') |
|
4241.9.5
by Vincent Ladeuil
Fix unicode related OSX failures. |
201 |
fname = u'\N{Euro Sign}.txt' |
|
5050.37.1
by Andrew Bennetts
Some fixes for tests that did not cope with LANG=C. |
202 |
self.build_tree(['zip/' + fname]) |
|
2024.2.1
by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile |
203 |
tree.add([fname]) |
204 |
tree.commit('first') |
|
205 |
||
206 |
os.chdir('zip') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
207 |
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 |
208 |
zfile = zipfile.ZipFile('test.zip') |
209 |
# all paths are prefixed with the base name of the zipfile
|
|
|
7045.1.6
by Jelmer Vernooij
Always pass in filenames as unicode for zipfiles. |
210 |
self.assertEqual(['test/' + fname], |
|
2024.2.1
by John Arbash Meinel
Fix bug #56815 by exporting paths in utf8 to tarfile and zipfile |
211 |
sorted(zfile.namelist())) |
|
1185.61.5
by Jamie Wilkinson
add test for directory export |
212 |
|
|
2024.2.6
by John Arbash Meinel
In zip files, directories must have trailing slashes |
213 |
def test_zip_export_directories(self): |
214 |
tree = self.make_branch_and_tree('zip') |
|
215 |
self.build_tree(['zip/a', 'zip/b/', 'zip/b/c', 'zip/d/']) |
|
216 |
tree.add(['a', 'b', 'b/c', 'd']) |
|
217 |
tree.commit('init') |
|
218 |
||
219 |
os.chdir('zip') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
220 |
self.run_bzr('export test.zip') |
|
2024.2.6
by John Arbash Meinel
In zip files, directories must have trailing slashes |
221 |
zfile = zipfile.ZipFile('test.zip') |
222 |
names = sorted(zfile.namelist()) |
|
|
2024.2.7
by John Arbash Meinel
Set the external_attr bits so Windows respects our directories |
223 |
|
|
2024.2.8
by John Arbash Meinel
paths are always forward slashed for python zipfiles |
224 |
# even on win32, zipfile.ZipFile changes all names to use
|
225 |
# forward slashes
|
|
226 |
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 |
227 |
|
|
6968.2.7
by Jelmer Vernooij
Add breezy.archive. |
228 |
file_attr = stat.S_IFREG | zip.FILE_PERMISSIONS |
229 |
dir_attr = (stat.S_IFDIR | zip.ZIP_DIRECTORY_BIT | |
|
230 |
zip.DIR_PERMISSIONS) |
|
|
2024.2.7
by John Arbash Meinel
Set the external_attr bits so Windows respects our directories |
231 |
|
232 |
a_info = zfile.getinfo(names[0]) |
|
233 |
self.assertEqual(file_attr, a_info.external_attr) |
|
234 |
||
235 |
b_info = zfile.getinfo(names[1]) |
|
236 |
self.assertEqual(dir_attr, b_info.external_attr) |
|
237 |
||
238 |
c_info = zfile.getinfo(names[2]) |
|
239 |
self.assertEqual(file_attr, c_info.external_attr) |
|
240 |
||
241 |
d_info = zfile.getinfo(names[3]) |
|
242 |
self.assertEqual(dir_attr, d_info.external_attr) |
|
|
2024.2.6
by John Arbash Meinel
In zip files, directories must have trailing slashes |
243 |
|
|
1185.61.5
by Jamie Wilkinson
add test for directory export |
244 |
def test_dir_export(self): |
|
2024.2.2
by John Arbash Meinel
Cleanup the export tests to act more like the current api. |
245 |
tree = self.make_branch_and_tree('dir') |
246 |
self.build_tree(['dir/a']) |
|
247 |
tree.add('a') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
248 |
self.build_tree_contents([('dir/.bzrrules', b'')]) |
|
3577.3.1
by Ian Clatworthy
do not export .bzrrules |
249 |
tree.add('.bzrrules') |
|
3577.3.2
by Ian Clatworthy
tweaks following jam's review |
250 |
self.build_tree(['dir/.bzr-adir/', 'dir/.bzr-adir/afile']) |
251 |
tree.add(['.bzr-adir/', '.bzr-adir/afile']) |
|
|
1185.61.5
by Jamie Wilkinson
add test for directory export |
252 |
|
253 |
os.chdir('dir') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
254 |
self.run_bzr('ignore something') |
|
2024.2.2
by John Arbash Meinel
Cleanup the export tests to act more like the current api. |
255 |
tree.commit('1') |
|
1185.61.5
by Jamie Wilkinson
add test for directory export |
256 |
|
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
257 |
self.assertTrue(tree.has_filename('.bzrignore')) |
258 |
self.assertTrue(tree.has_filename('.bzrrules')) |
|
259 |
self.assertTrue(tree.has_filename('.bzr-adir')) |
|
260 |
self.assertTrue(tree.has_filename('.bzr-adir/afile')) |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
261 |
self.run_bzr('export direxport') |
|
1185.61.5
by Jamie Wilkinson
add test for directory export |
262 |
|
263 |
files = sorted(os.listdir('direxport')) |
|
|
2024.2.2
by John Arbash Meinel
Cleanup the export tests to act more like the current api. |
264 |
# Make sure the exported directory contains 'a', but does not contain
|
265 |
# '.bzrignore'.
|
|
266 |
self.assertEqual(['a'], files) |
|
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
267 |
|
268 |
def example_branch(self): |
|
|
3613.2.1
by Robert Collins
Teach export how to export a subdirectory. (Robert Collins) |
269 |
"""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 |
270 |
tree = self.make_branch_and_tree('branch') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
271 |
self.build_tree_contents([('branch/hello', b'foo')]) |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
272 |
tree.add('hello') |
273 |
tree.commit('setup') |
|
274 |
||
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
275 |
self.build_tree_contents([('branch/goodbye', b'baz')]) |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
276 |
tree.add('goodbye') |
277 |
tree.commit('setup') |
|
278 |
return tree |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
279 |
|
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
280 |
def test_basic_directory_export(self): |
281 |
self.example_branch() |
|
282 |
os.chdir('branch') |
|
283 |
||
284 |
# Directory exports
|
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
285 |
self.run_bzr('export ../latest') |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
286 |
self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('../latest'))) |
|
6973.10.4
by Jelmer Vernooij
Update python3.passing. |
287 |
self.check_file_contents('../latest/goodbye', b'baz') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
288 |
self.run_bzr('export ../first -r 1') |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
289 |
self.assertEqual(['hello'], sorted(os.listdir('../first'))) |
|
6973.10.4
by Jelmer Vernooij
Update python3.passing. |
290 |
self.check_file_contents('../first/hello', b'foo') |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
291 |
|
292 |
# Even with .gz and .bz2 it is still a directory
|
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
293 |
self.run_bzr('export ../first.gz -r 1') |
|
6973.10.4
by Jelmer Vernooij
Update python3.passing. |
294 |
self.check_file_contents('../first.gz/hello', b'foo') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
295 |
self.run_bzr('export ../first.bz2 -r 1') |
|
6973.10.4
by Jelmer Vernooij
Update python3.passing. |
296 |
self.check_file_contents('../first.bz2/hello', b'foo') |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
297 |
|
298 |
def test_basic_tarfile_export(self): |
|
299 |
self.example_branch() |
|
300 |
os.chdir('branch') |
|
301 |
||
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
302 |
self.run_bzr('export ../first.tar -r 1') |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
303 |
self.assertTrue(os.path.isfile('../first.tar')) |
|
7356.1.5
by Jelmer Vernooij
Use more ExitStacks. |
304 |
with tarfile.open('../first.tar') as tf: |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
305 |
self.assertEqual(['first/hello'], sorted(tf.getnames())) |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
306 |
self.assertEqual(b'foo', tf.extractfile('first/hello').read()) |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
307 |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
308 |
self.run_bzr('export ../first.tar.gz -r 1') |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
309 |
self.assertTrue(os.path.isfile('../first.tar.gz')) |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
310 |
self.run_bzr('export ../first.tbz2 -r 1') |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
311 |
self.assertTrue(os.path.isfile('../first.tbz2')) |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
312 |
self.run_bzr('export ../first.tar.bz2 -r 1') |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
313 |
self.assertTrue(os.path.isfile('../first.tar.bz2')) |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
314 |
self.run_bzr('export ../first.tar.tbz2 -r 1') |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
315 |
self.assertTrue(os.path.isfile('../first.tar.tbz2')) |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
316 |
|
|
7356.1.5
by Jelmer Vernooij
Use more ExitStacks. |
317 |
with tarfile.open('../first.tar.tbz2', 'r:bz2') as tf: |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
318 |
self.assertEqual(['first.tar/hello'], sorted(tf.getnames())) |
|
7027.10.2
by Jelmer Vernooij
Merge trunk. |
319 |
self.assertEqual(b'foo', tf.extractfile('first.tar/hello').read()) |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
320 |
self.run_bzr('export ../first2.tar -r 1 --root pizza') |
|
7356.1.5
by Jelmer Vernooij
Use more ExitStacks. |
321 |
with tarfile.open('../first2.tar') as tf: |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
322 |
self.assertEqual(['pizza/hello'], sorted(tf.getnames())) |
|
7027.10.1
by Jelmer Vernooij
Various blackbox test fixes. |
323 |
self.assertEqual(b'foo', tf.extractfile('pizza/hello').read()) |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
324 |
|
325 |
def test_basic_zipfile_export(self): |
|
326 |
self.example_branch() |
|
327 |
os.chdir('branch') |
|
328 |
||
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
329 |
self.run_bzr('export ../first.zip -r 1') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
330 |
self.assertPathExists('../first.zip') |
|
7356.1.5
by Jelmer Vernooij
Use more ExitStacks. |
331 |
with zipfile.ZipFile('../first.zip') as zf: |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
332 |
self.assertEqual(['first/hello'], sorted(zf.namelist())) |
|
7045.3.1
by Jelmer Vernooij
Fix another ~500 tests. |
333 |
self.assertEqual(b'foo', zf.read('first/hello')) |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
334 |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
335 |
self.run_bzr('export ../first2.zip -r 1 --root pizza') |
|
7356.1.5
by Jelmer Vernooij
Use more ExitStacks. |
336 |
with zipfile.ZipFile('../first2.zip') as zf: |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
337 |
self.assertEqual(['pizza/hello'], sorted(zf.namelist())) |
|
7045.3.1
by Jelmer Vernooij
Fix another ~500 tests. |
338 |
self.assertEqual(b'foo', zf.read('pizza/hello')) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
339 |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
340 |
self.run_bzr('export ../first-zip --format=zip -r 1') |
|
7356.1.5
by Jelmer Vernooij
Use more ExitStacks. |
341 |
with zipfile.ZipFile('../first-zip') as zf: |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
342 |
self.assertEqual(['first-zip/hello'], sorted(zf.namelist())) |
|
7045.3.1
by Jelmer Vernooij
Fix another ~500 tests. |
343 |
self.assertEqual(b'foo', zf.read('first-zip/hello')) |
|
2024.2.3
by John Arbash Meinel
Move out export tests from test_too_much, refactor |
344 |
|
|
2099.1.1
by Daniel Silverstone
Add source branch support to export command |
345 |
def test_export_from_outside_branch(self): |
346 |
self.example_branch() |
|
347 |
||
348 |
# Use directory exports to test stating the branch location
|
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
349 |
self.run_bzr('export latest branch') |
|
2099.1.1
by Daniel Silverstone
Add source branch support to export command |
350 |
self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('latest'))) |
|
6973.10.4
by Jelmer Vernooij
Update python3.passing. |
351 |
self.check_file_contents('latest/goodbye', b'baz') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
352 |
self.run_bzr('export first -r 1 branch') |
|
2099.1.1
by Daniel Silverstone
Add source branch support to export command |
353 |
self.assertEqual(['hello'], sorted(os.listdir('first'))) |
|
6973.10.4
by Jelmer Vernooij
Update python3.passing. |
354 |
self.check_file_contents('first/hello', b'foo') |
|
3613.2.1
by Robert Collins
Teach export how to export a subdirectory. (Robert Collins) |
355 |
|
356 |
def test_export_partial_tree(self): |
|
357 |
tree = self.example_branch() |
|
358 |
self.build_tree(['branch/subdir/', 'branch/subdir/foo.txt']) |
|
359 |
tree.smart_add(['branch']) |
|
360 |
tree.commit('more setup') |
|
361 |
out, err = self.run_bzr('export exported branch/subdir') |
|
362 |
self.assertEqual(['foo.txt'], os.listdir('exported')) |
|
|
5076.2.2
by Jelmer Vernooij
``bzr export`` now takes an optional argument ``--use-tree-timestamp`` |
363 |
|
|
5076.2.3
by Jelmer Vernooij
Review comments from Rob. |
364 |
def test_dir_export_per_file_timestamps(self): |
|
5076.2.2
by Jelmer Vernooij
``bzr export`` now takes an optional argument ``--use-tree-timestamp`` |
365 |
tree = self.example_branch() |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
366 |
self.build_tree_contents([('branch/har', b'foo')]) |
|
5076.2.2
by Jelmer Vernooij
``bzr export`` now takes an optional argument ``--use-tree-timestamp`` |
367 |
tree.add('har') |
|
5151.3.1
by Martin
Fix os.utime test failures, three on FAT filesystems and one with readonly files |
368 |
# Earliest allowable date on FAT32 filesystems is 1980-01-01
|
369 |
tree.commit('setup', timestamp=315532800) |
|
|
5076.2.3
by Jelmer Vernooij
Review comments from Rob. |
370 |
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`` |
371 |
har_st = os.stat('t/har') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
372 |
self.assertEqual(315532800, har_st.st_mtime) |
|
5076.2.2
by Jelmer Vernooij
``bzr export`` now takes an optional argument ``--use-tree-timestamp`` |
373 |
|
|
5966.1.1
by Szilveszter Farkas
Fixed exporting subdirectories with per file timestamps. |
374 |
def test_dir_export_partial_tree_per_file_timestamps(self): |
375 |
tree = self.example_branch() |
|
376 |
self.build_tree(['branch/subdir/', 'branch/subdir/foo.txt']) |
|
377 |
tree.smart_add(['branch']) |
|
378 |
# Earliest allowable date on FAT32 filesystems is 1980-01-01
|
|
379 |
tree.commit('setup', timestamp=315532800) |
|
380 |
self.run_bzr('export --per-file-timestamps tpart branch/subdir') |
|
381 |
foo_st = os.stat('tpart/foo.txt') |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
382 |
self.assertEqual(315532800, foo_st.st_mtime) |
|
5966.1.1
by Szilveszter Farkas
Fixed exporting subdirectories with per file timestamps. |
383 |
|
|
5171.3.7
by Martin von Gagern
Added blackbox tests for --directory option. |
384 |
def test_export_directory(self): |
385 |
"""Test --directory option""" |
|
386 |
self.example_branch() |
|
387 |
self.run_bzr(['export', '--directory=branch', 'latest']) |
|
388 |
self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('latest'))) |
|
|
6973.10.4
by Jelmer Vernooij
Update python3.passing. |
389 |
self.check_file_contents('latest/goodbye', b'baz') |
|
5718.5.13
by Jelmer Vernooij
Add test for zip with per-file-timestamps. |
390 |
|
|
6331.2.2
by Jelmer Vernooij
Add --uncommitted option to export. |
391 |
def test_export_uncommitted(self): |
392 |
"""Test --uncommitted option""" |
|
393 |
self.example_branch() |
|
394 |
os.chdir('branch') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
395 |
self.build_tree_contents([('goodbye', b'uncommitted data')]) |
|
6331.2.2
by Jelmer Vernooij
Add --uncommitted option to export. |
396 |
self.run_bzr(['export', '--uncommitted', 'latest']) |
|
6973.10.4
by Jelmer Vernooij
Update python3.passing. |
397 |
self.check_file_contents('latest/goodbye', b'uncommitted data') |
|
6331.2.2
by Jelmer Vernooij
Add --uncommitted option to export. |
398 |
|
399 |
def test_export_uncommitted_no_tree(self): |
|
400 |
"""Test --uncommitted option only works with a working tree.""" |
|
401 |
tree = self.example_branch() |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
402 |
tree.controldir.destroy_workingtree() |
|
6331.2.2
by Jelmer Vernooij
Add --uncommitted option to export. |
403 |
os.chdir('branch') |
404 |
self.run_bzr_error( |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
405 |
['brz: ERROR: --uncommitted requires a working tree'], |
|
6331.2.2
by Jelmer Vernooij
Add --uncommitted option to export. |
406 |
'export --uncommitted latest') |
407 |
||
|
5718.5.13
by Jelmer Vernooij
Add test for zip with per-file-timestamps. |
408 |
def test_zip_export_per_file_timestamps(self): |
409 |
tree = self.example_branch() |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
410 |
self.build_tree_contents([('branch/har', b'foo')]) |
|
5718.5.13
by Jelmer Vernooij
Add test for zip with per-file-timestamps. |
411 |
tree.add('har') |
412 |
# Earliest allowable date on FAT32 filesystems is 1980-01-01
|
|
|
5718.5.26
by Jelmer Vernooij
Work around zip info time zone issues. |
413 |
timestamp = 347151600 |
414 |
tree.commit('setup', timestamp=timestamp) |
|
|
5718.5.13
by Jelmer Vernooij
Add test for zip with per-file-timestamps. |
415 |
self.run_bzr('export --per-file-timestamps test.zip branch') |
416 |
zfile = zipfile.ZipFile('test.zip') |
|
417 |
info = zfile.getinfo("test/har") |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
418 |
self.assertEqual(time.localtime(timestamp)[:6], info.date_time) |