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) 2009, 2010, 2011, 2016 Canonical Ltd
|
|
4010.2.1
by James Westby
Handle files that are not present in the tree when exporting (#174539) |
2 |
#
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
4010.2.1
by James Westby
Handle files that are not present in the tree when exporting (#174539) |
16 |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
17 |
"""Tests for breezy.export."""
|
|
5718.5.12
by Jelmer Vernooij
Add test for export_tarball. |
18 |
|
|
7240.8.1
by Jelmer Vernooij
Use tree timestamp when exporting. |
19 |
import gzip |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
20 |
from io import BytesIO |
|
4010.2.1
by James Westby
Handle files that are not present in the tree when exporting (#174539) |
21 |
import os |
|
5718.5.10
by Jelmer Vernooij
Support creating .tar.xz files. |
22 |
import tarfile |
|
4996.1.1
by Robert Collins
Set the file mtime when exporting to a directory to prevent triggering make rebuilds unnecessarily. |
23 |
import time |
|
5718.5.14
by Jelmer Vernooij
Add test for per-file-timestamp zipfiles. |
24 |
import zipfile |
|
4241.9.5
by Vincent Ladeuil
Fix unicode related OSX failures. |
25 |
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
26 |
from .. import ( |
|
4576.1.1
by Alexander Belchenko
Fixed export to existing empty directory. |
27 |
errors, |
|
4241.9.5
by Vincent Ladeuil
Fix unicode related OSX failures. |
28 |
export, |
29 |
tests, |
|
30 |
)
|
|
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
31 |
from ..export import get_root_name |
|
6968.2.7
by Jelmer Vernooij
Add breezy.archive. |
32 |
from ..archive.tar import tarball_generator |
|
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
33 |
from . import features |
|
4241.9.5
by Vincent Ladeuil
Fix unicode related OSX failures. |
34 |
|
35 |
||
|
5718.5.9
by Jelmer Vernooij
Add test for export zip to stdout. |
36 |
class TestDirExport(tests.TestCaseWithTransport): |
|
4010.2.1
by James Westby
Handle files that are not present in the tree when exporting (#174539) |
37 |
|
|
5718.5.10
by Jelmer Vernooij
Support creating .tar.xz files. |
38 |
def test_missing_file(self): |
|
4010.2.1
by James Westby
Handle files that are not present in the tree when exporting (#174539) |
39 |
self.build_tree(['a/', 'a/b', 'a/c']) |
40 |
wt = self.make_branch_and_tree('.') |
|
41 |
wt.add(['a', 'a/b', 'a/c']) |
|
42 |
os.unlink('a/c') |
|
|
4241.9.5
by Vincent Ladeuil
Fix unicode related OSX failures. |
43 |
export.export(wt, 'target', format="dir") |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
44 |
self.assertPathExists('target/a/b') |
45 |
self.assertPathDoesNotExist('target/a/c') |
|
|
4241.9.5
by Vincent Ladeuil
Fix unicode related OSX failures. |
46 |
|
|
5718.5.10
by Jelmer Vernooij
Support creating .tar.xz files. |
47 |
def test_empty(self): |
48 |
wt = self.make_branch_and_tree('.') |
|
49 |
export.export(wt, 'target', format="dir") |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
50 |
self.assertEqual([], os.listdir("target")) |
|
5718.5.10
by Jelmer Vernooij
Support creating .tar.xz files. |
51 |
|
52 |
def test_symlink(self): |
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
53 |
self.requireFeature(features.SymlinkFeature) |
|
4562.1.1
by Jelmer Vernooij
Support exporting symlinks when exporting from a working tree. |
54 |
wt = self.make_branch_and_tree('.') |
55 |
os.symlink('source', 'link') |
|
56 |
wt.add(['link']) |
|
57 |
export.export(wt, 'target', format="dir") |
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
58 |
self.assertPathExists('target/link') |
|
4576.1.1
by Alexander Belchenko
Fixed export to existing empty directory. |
59 |
|
|
6964.1.1
by Jelmer Vernooij
Support exporting nested trees. |
60 |
def test_nested_tree(self): |
61 |
wt = self.make_branch_and_tree('.', format='development-subtree') |
|
62 |
subtree = self.make_branch_and_tree('subtree') |
|
63 |
self.build_tree(['subtree/file']) |
|
64 |
subtree.add(['file']) |
|
65 |
wt.add(['subtree']) |
|
66 |
export.export(wt, 'target', format="dir") |
|
67 |
self.assertPathExists('target/subtree') |
|
68 |
# TODO(jelmer): Once iter_entries_by_dir supports nested tree iteration:
|
|
69 |
# self.assertPathExists('target/subtree/file')
|
|
70 |
||
|
5718.5.10
by Jelmer Vernooij
Support creating .tar.xz files. |
71 |
def test_to_existing_empty_dir_success(self): |
|
4576.1.1
by Alexander Belchenko
Fixed export to existing empty directory. |
72 |
self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c']) |
73 |
wt = self.make_branch_and_tree('source') |
|
74 |
wt.add(['a', 'b', 'b/c']) |
|
75 |
wt.commit('1') |
|
76 |
self.build_tree(['target/']) |
|
77 |
export.export(wt, 'target', format="dir") |
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
78 |
self.assertPathExists('target/a') |
79 |
self.assertPathExists('target/b') |
|
80 |
self.assertPathExists('target/b/c') |
|
|
4576.1.1
by Alexander Belchenko
Fixed export to existing empty directory. |
81 |
|
|
5809.3.1
by Aaron Bentley
Switch to iter_entries_by_dir. |
82 |
def test_empty_subdir(self): |
83 |
self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c']) |
|
84 |
wt = self.make_branch_and_tree('source') |
|
85 |
wt.add(['a', 'b', 'b/c']) |
|
86 |
wt.commit('1') |
|
87 |
self.build_tree(['target/']) |
|
88 |
export.export(wt, 'target', format="dir", subdir='') |
|
89 |
self.assertPathExists('target/a') |
|
90 |
self.assertPathExists('target/b') |
|
91 |
self.assertPathExists('target/b/c') |
|
92 |
||
|
5718.5.10
by Jelmer Vernooij
Support creating .tar.xz files. |
93 |
def test_to_existing_nonempty_dir_fail(self): |
|
4576.1.1
by Alexander Belchenko
Fixed export to existing empty directory. |
94 |
self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c']) |
95 |
wt = self.make_branch_and_tree('source') |
|
96 |
wt.add(['a', 'b', 'b/c']) |
|
97 |
wt.commit('1') |
|
98 |
self.build_tree(['target/', 'target/foo']) |
|
|
5967.6.2
by Martin Pool
Delete fairly useless and repetitive per-format export single-call functions. |
99 |
self.assertRaises(errors.BzrError, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
100 |
export.export, wt, 'target', format="dir") |
|
4988.10.1
by michal
- bug #511987 fixed, export of single file |
101 |
|
|
5718.5.10
by Jelmer Vernooij
Support creating .tar.xz files. |
102 |
def test_existing_single_file(self): |
|
5967.6.2
by Martin Pool
Delete fairly useless and repetitive per-format export single-call functions. |
103 |
self.build_tree([ |
104 |
'dir1/', 'dir1/dir2/', 'dir1/first', 'dir1/dir2/second']) |
|
|
4988.10.1
by michal
- bug #511987 fixed, export of single file |
105 |
wtree = self.make_branch_and_tree('dir1') |
106 |
wtree.add(['dir2', 'first', 'dir2/second']) |
|
107 |
wtree.commit('1') |
|
108 |
export.export(wtree, 'target1', format='dir', subdir='first') |
|
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
109 |
self.assertPathExists('target1/first') |
|
4988.10.1
by michal
- bug #511987 fixed, export of single file |
110 |
export.export(wtree, 'target2', format='dir', subdir='dir2/second') |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
111 |
self.assertPathExists('target2/second') |
|
5718.5.7
by Jelmer Vernooij
Support bzr zip exporting to stdout. |
112 |
|
|
5718.5.10
by Jelmer Vernooij
Support creating .tar.xz files. |
113 |
def test_files_same_timestamp(self): |
|
4996.1.1
by Robert Collins
Set the file mtime when exporting to a directory to prevent triggering make rebuilds unnecessarily. |
114 |
builder = self.make_branch_builder('source') |
115 |
builder.start_series() |
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
116 |
builder.build_snapshot(None, [ |
|
6973.11.1
by Jelmer Vernooij
Fix export_pot. |
117 |
('add', ('', b'root-id', 'directory', '')), |
118 |
('add', ('a', b'a-id', 'file', b'content\n'))]) |
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
119 |
builder.build_snapshot(None, [ |
|
6973.11.1
by Jelmer Vernooij
Fix export_pot. |
120 |
('add', ('b', b'b-id', 'file', b'content\n'))]) |
|
4996.1.1
by Robert Collins
Set the file mtime when exporting to a directory to prevent triggering make rebuilds unnecessarily. |
121 |
builder.finish_series() |
122 |
b = builder.get_branch() |
|
123 |
b.lock_read() |
|
124 |
self.addCleanup(b.unlock) |
|
125 |
tree = b.basis_tree() |
|
126 |
orig_iter_files_bytes = tree.iter_files_bytes |
|
|
5967.6.2
by Martin Pool
Delete fairly useless and repetitive per-format export single-call functions. |
127 |
|
|
4996.1.1
by Robert Collins
Set the file mtime when exporting to a directory to prevent triggering make rebuilds unnecessarily. |
128 |
# Make iter_files_bytes slower, so we provoke mtime skew
|
129 |
def iter_files_bytes(to_fetch): |
|
130 |
for thing in orig_iter_files_bytes(to_fetch): |
|
131 |
yield thing |
|
132 |
time.sleep(1) |
|
133 |
tree.iter_files_bytes = iter_files_bytes |
|
134 |
export.export(tree, 'target', format='dir') |
|
135 |
t = self.get_transport('target') |
|
136 |
st_a = t.stat('a') |
|
137 |
st_b = t.stat('b') |
|
138 |
# All files must be given the same mtime.
|
|
139 |
self.assertEqual(st_a.st_mtime, st_b.st_mtime) |
|
|
5076.2.1
by Jelmer Vernooij
Add use_tree_timestamp argument to exporters. |
140 |
|
|
5718.5.10
by Jelmer Vernooij
Support creating .tar.xz files. |
141 |
def test_files_per_file_timestamps(self): |
|
5076.2.1
by Jelmer Vernooij
Add use_tree_timestamp argument to exporters. |
142 |
builder = self.make_branch_builder('source') |
143 |
builder.start_series() |
|
|
5151.3.1
by Martin
Fix os.utime test failures, three on FAT filesystems and one with readonly files |
144 |
# Earliest allowable date on FAT32 filesystems is 1980-01-01
|
145 |
a_time = time.mktime((1999, 12, 12, 0, 0, 0, 0, 0, 0)) |
|
|
6619.3.14
by Jelmer Vernooij
Convert some octal numbers to new notations. |
146 |
b_time = time.mktime((1980, 0o1, 0o1, 0, 0, 0, 0, 0, 0)) |
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
147 |
builder.build_snapshot(None, [ |
|
6973.11.1
by Jelmer Vernooij
Fix export_pot. |
148 |
('add', ('', b'root-id', 'directory', '')), |
149 |
('add', ('a', b'a-id', 'file', b'content\n'))], |
|
|
5151.3.1
by Martin
Fix os.utime test failures, three on FAT filesystems and one with readonly files |
150 |
timestamp=a_time) |
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
151 |
builder.build_snapshot(None, [ |
|
6973.11.1
by Jelmer Vernooij
Fix export_pot. |
152 |
('add', ('b', b'b-id', 'file', b'content\n'))], |
|
5151.3.1
by Martin
Fix os.utime test failures, three on FAT filesystems and one with readonly files |
153 |
timestamp=b_time) |
|
5076.2.1
by Jelmer Vernooij
Add use_tree_timestamp argument to exporters. |
154 |
builder.finish_series() |
155 |
b = builder.get_branch() |
|
156 |
b.lock_read() |
|
157 |
self.addCleanup(b.unlock) |
|
158 |
tree = b.basis_tree() |
|
|
5076.2.3
by Jelmer Vernooij
Review comments from Rob. |
159 |
export.export(tree, 'target', format='dir', per_file_timestamps=True) |
|
5076.2.1
by Jelmer Vernooij
Add use_tree_timestamp argument to exporters. |
160 |
t = self.get_transport('target') |
|
5151.3.1
by Martin
Fix os.utime test failures, three on FAT filesystems and one with readonly files |
161 |
self.assertEqual(a_time, t.stat('a').st_mtime) |
162 |
self.assertEqual(b_time, t.stat('b').st_mtime) |
|
|
5718.5.10
by Jelmer Vernooij
Support creating .tar.xz files. |
163 |
|
|
5966.1.1
by Szilveszter Farkas
Fixed exporting subdirectories with per file timestamps. |
164 |
def test_subdir_files_per_timestamps(self): |
165 |
builder = self.make_branch_builder('source') |
|
166 |
builder.start_series() |
|
167 |
foo_time = time.mktime((1999, 12, 12, 0, 0, 0, 0, 0, 0)) |
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
168 |
builder.build_snapshot(None, [ |
|
6973.11.1
by Jelmer Vernooij
Fix export_pot. |
169 |
('add', ('', b'root-id', 'directory', '')), |
170 |
('add', ('subdir', b'subdir-id', 'directory', '')), |
|
171 |
('add', ('subdir/foo.txt', b'foo-id', 'file', b'content\n'))], |
|
|
5966.1.1
by Szilveszter Farkas
Fixed exporting subdirectories with per file timestamps. |
172 |
timestamp=foo_time) |
173 |
builder.finish_series() |
|
174 |
b = builder.get_branch() |
|
175 |
b.lock_read() |
|
176 |
self.addCleanup(b.unlock) |
|
177 |
tree = b.basis_tree() |
|
178 |
export.export(tree, 'target', format='dir', subdir='subdir', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
179 |
per_file_timestamps=True) |
|
5966.1.1
by Szilveszter Farkas
Fixed exporting subdirectories with per file timestamps. |
180 |
t = self.get_transport('target') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
181 |
self.assertEqual(foo_time, t.stat('foo.txt').st_mtime) |
|
5966.1.1
by Szilveszter Farkas
Fixed exporting subdirectories with per file timestamps. |
182 |
|
|
5718.5.10
by Jelmer Vernooij
Support creating .tar.xz files. |
183 |
|
184 |
class TarExporterTests(tests.TestCaseWithTransport): |
|
185 |
||
|
5718.5.11
by Jelmer Vernooij
Tests, tests, tests. |
186 |
def test_xz(self): |
|
5718.5.19
by Jelmer Vernooij
Use features. |
187 |
self.requireFeature(features.lzma) |
188 |
import lzma |
|
|
5718.5.11
by Jelmer Vernooij
Tests, tests, tests. |
189 |
wt = self.make_branch_and_tree('.') |
190 |
self.build_tree(['a']) |
|
191 |
wt.add(["a"]) |
|
192 |
wt.commit("1") |
|
|
5718.5.19
by Jelmer Vernooij
Use features. |
193 |
export.export(wt, 'target.tar.xz', format="txz") |
|
5718.5.11
by Jelmer Vernooij
Tests, tests, tests. |
194 |
tf = tarfile.open(fileobj=lzma.LZMAFile('target.tar.xz')) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
195 |
self.assertEqual(["target/a"], tf.getnames()) |
|
5718.5.11
by Jelmer Vernooij
Tests, tests, tests. |
196 |
|
|
5718.5.17
by Jelmer Vernooij
Support tar.lzma. |
197 |
def test_lzma(self): |
|
5718.5.19
by Jelmer Vernooij
Use features. |
198 |
self.requireFeature(features.lzma) |
199 |
import lzma |
|
|
5718.5.17
by Jelmer Vernooij
Support tar.lzma. |
200 |
wt = self.make_branch_and_tree('.') |
201 |
self.build_tree(['a']) |
|
202 |
wt.add(["a"]) |
|
203 |
wt.commit("1") |
|
|
5718.5.19
by Jelmer Vernooij
Use features. |
204 |
export.export(wt, 'target.tar.lzma', format="tlzma") |
|
5718.5.17
by Jelmer Vernooij
Support tar.lzma. |
205 |
tf = tarfile.open(fileobj=lzma.LZMAFile('target.tar.lzma')) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
206 |
self.assertEqual(["target/a"], tf.getnames()) |
|
5718.5.17
by Jelmer Vernooij
Support tar.lzma. |
207 |
|
|
5718.5.11
by Jelmer Vernooij
Tests, tests, tests. |
208 |
def test_tgz(self): |
209 |
wt = self.make_branch_and_tree('.') |
|
210 |
self.build_tree(['a']) |
|
211 |
wt.add(["a"]) |
|
212 |
wt.commit("1") |
|
213 |
export.export(wt, 'target.tar.gz', format="tgz") |
|
214 |
tf = tarfile.open('target.tar.gz') |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
215 |
self.assertEqual(["target/a"], tf.getnames()) |
|
5718.5.11
by Jelmer Vernooij
Tests, tests, tests. |
216 |
|
|
7240.8.1
by Jelmer Vernooij
Use tree timestamp when exporting. |
217 |
def test_tgz_consistent_mtime(self): |
218 |
wt = self.make_branch_and_tree('.') |
|
219 |
self.build_tree(['a']) |
|
220 |
wt.add(["a"]) |
|
221 |
timestamp = 1547400500 |
|
222 |
revid = wt.commit("1", timestamp=timestamp) |
|
223 |
revtree = wt.branch.repository.revision_tree(revid) |
|
224 |
export.export(revtree, 'target.tar.gz', format="tgz") |
|
225 |
with gzip.GzipFile('target.tar.gz', 'r') as f: |
|
226 |
f.read() |
|
227 |
self.assertEqual(int(f.mtime), timestamp) |
|
228 |
||
|
5718.5.15
by Jelmer Vernooij
Only write out basename of the tarfile to the gzip file. |
229 |
def test_tgz_ignores_dest_path(self): |
230 |
# The target path should not be a part of the target file.
|
|
231 |
# (bug #102234)
|
|
232 |
wt = self.make_branch_and_tree('.') |
|
233 |
self.build_tree(['a']) |
|
234 |
wt.add(["a"]) |
|
235 |
wt.commit("1") |
|
236 |
os.mkdir("testdir1") |
|
237 |
os.mkdir("testdir2") |
|
238 |
export.export(wt, 'testdir1/target.tar.gz', format="tgz", |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
239 |
per_file_timestamps=True) |
|
5718.5.15
by Jelmer Vernooij
Only write out basename of the tarfile to the gzip file. |
240 |
export.export(wt, 'testdir2/target.tar.gz', format="tgz", |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
241 |
per_file_timestamps=True) |
|
6973.11.1
by Jelmer Vernooij
Fix export_pot. |
242 |
file1 = open('testdir1/target.tar.gz', 'rb') |
|
5718.5.15
by Jelmer Vernooij
Only write out basename of the tarfile to the gzip file. |
243 |
self.addCleanup(file1.close) |
|
6973.11.1
by Jelmer Vernooij
Fix export_pot. |
244 |
file2 = open('testdir1/target.tar.gz', 'rb') |
|
5718.5.15
by Jelmer Vernooij
Only write out basename of the tarfile to the gzip file. |
245 |
self.addCleanup(file2.close) |
246 |
content1 = file1.read() |
|
247 |
content2 = file2.read() |
|
248 |
self.assertEqualDiff(content1, content2) |
|
249 |
# the gzip module doesn't have a way to read back to the original
|
|
250 |
# filename, but it's stored as-is in the tarfile.
|
|
|
6973.11.1
by Jelmer Vernooij
Fix export_pot. |
251 |
self.assertFalse(b"testdir1" in content1) |
252 |
self.assertFalse(b"target.tar.gz" in content1) |
|
253 |
self.assertTrue(b"target.tar" in content1) |
|
|
5718.5.15
by Jelmer Vernooij
Only write out basename of the tarfile to the gzip file. |
254 |
|
|
5718.5.11
by Jelmer Vernooij
Tests, tests, tests. |
255 |
def test_tbz2(self): |
256 |
wt = self.make_branch_and_tree('.') |
|
257 |
self.build_tree(['a']) |
|
258 |
wt.add(["a"]) |
|
259 |
wt.commit("1") |
|
260 |
export.export(wt, 'target.tar.bz2', format="tbz2") |
|
261 |
tf = tarfile.open('target.tar.bz2') |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
262 |
self.assertEqual(["target/a"], tf.getnames()) |
|
5718.5.11
by Jelmer Vernooij
Tests, tests, tests. |
263 |
|
|
5967.6.2
by Martin Pool
Delete fairly useless and repetitive per-format export single-call functions. |
264 |
def test_export_tarball_generator(self): |
|
5718.5.12
by Jelmer Vernooij
Add test for export_tarball. |
265 |
wt = self.make_branch_and_tree('.') |
266 |
self.build_tree(['a']) |
|
267 |
wt.add(["a"]) |
|
268 |
wt.commit("1", timestamp=42) |
|
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
269 |
target = BytesIO() |
|
6968.2.7
by Jelmer Vernooij
Add breezy.archive. |
270 |
with wt.lock_read(): |
271 |
target.writelines(tarball_generator(wt, "bar")) |
|
|
5967.6.3
by Martin Pool
Further shrink export code |
272 |
# Ball should now be closed.
|
273 |
target.seek(0) |
|
274 |
ball2 = tarfile.open(None, "r", target) |
|
275 |
self.addCleanup(ball2.close) |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
276 |
self.assertEqual(["bar/a"], ball2.getnames()) |
|
5718.5.14
by Jelmer Vernooij
Add test for per-file-timestamp zipfiles. |
277 |
|
278 |
||
279 |
class ZipExporterTests(tests.TestCaseWithTransport): |
|
280 |
||
281 |
def test_per_file_timestamps(self): |
|
282 |
tree = self.make_branch_and_tree('.') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
283 |
self.build_tree_contents([('har', b'foo')]) |
|
5718.5.14
by Jelmer Vernooij
Add test for per-file-timestamp zipfiles. |
284 |
tree.add('har') |
285 |
# Earliest allowable date on FAT32 filesystems is 1980-01-01
|
|
|
5718.5.26
by Jelmer Vernooij
Work around zip info time zone issues. |
286 |
timestamp = 347151600 |
287 |
tree.commit('setup', timestamp=timestamp) |
|
|
5718.5.14
by Jelmer Vernooij
Add test for per-file-timestamp zipfiles. |
288 |
export.export(tree.basis_tree(), 'test.zip', format='zip', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
289 |
per_file_timestamps=True) |
|
5718.5.14
by Jelmer Vernooij
Add test for per-file-timestamp zipfiles. |
290 |
zfile = zipfile.ZipFile('test.zip') |
291 |
info = zfile.getinfo("test/har") |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
292 |
self.assertEqual(time.localtime(timestamp)[:6], info.date_time) |
|
5718.5.18
by Jelmer Vernooij
Don't export to '-', but rather to ''. |
293 |
|
294 |
||
295 |
class RootNameTests(tests.TestCase): |
|
296 |
||
297 |
def test_root_name(self): |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
298 |
self.assertEqual('mytest', get_root_name('../mytest.tar')) |
299 |
self.assertEqual('mytar', get_root_name('mytar.tar')) |
|
300 |
self.assertEqual('mytar', get_root_name('mytar.tar.bz2')) |
|
301 |
self.assertEqual('tar.tar.tar', get_root_name('tar.tar.tar.tgz')) |
|
302 |
self.assertEqual('bzr-0.0.5', get_root_name('bzr-0.0.5.tar.gz')) |
|
303 |
self.assertEqual('bzr-0.0.5', get_root_name('bzr-0.0.5.zip')) |
|
304 |
self.assertEqual('bzr-0.0.5', get_root_name('bzr-0.0.5')) |
|
305 |
self.assertEqual('mytar', get_root_name('a/long/path/mytar.tgz')) |
|
306 |
self.assertEqual('other', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
307 |
get_root_name('../parent/../dir/other.tbz2')) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
308 |
self.assertEqual('', get_root_name('-')) |