bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
5809.3.3
by Aaron Bentley
Test directories. |
1 |
# Copyright (C) 2011 Canonical Ltd
|
|
5809.3.1
by Aaron Bentley
Switch to iter_entries_by_dir. |
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
|
|
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
||
17 |
from __future__ import with_statement |
|
18 |
||
19 |
import contextlib |
|
|
5809.3.3
by Aaron Bentley
Test directories. |
20 |
import tarfile |
|
5809.3.1
by Aaron Bentley
Switch to iter_entries_by_dir. |
21 |
|
22 |
from bzrlib.export import export |
|
23 |
from bzrlib.tests.per_tree import TestCaseWithTree |
|
24 |
||
25 |
@contextlib.contextmanager |
|
26 |
def write_locked(tree): |
|
27 |
tree.lock_write() |
|
28 |
try: |
|
29 |
yield
|
|
30 |
finally: |
|
31 |
tree.unlock() |
|
32 |
||
33 |
class TestExport(TestCaseWithTree): |
|
34 |
||
35 |
def test_export_tar(self): |
|
36 |
work_a = self.make_branch_and_tree('wta') |
|
|
5809.3.3
by Aaron Bentley
Test directories. |
37 |
self.build_tree_contents( |
38 |
[('wta/file', 'a\nb\nc\nd\n'), ('wta/dir', '')]) |
|
|
5809.3.2
by Aaron Bentley
Support PreviewTree.has_filename. |
39 |
work_a.add('file', 'file-id') |
|
5809.3.3
by Aaron Bentley
Test directories. |
40 |
work_a.add('dir', 'dir-id') |
|
5809.3.2
by Aaron Bentley
Support PreviewTree.has_filename. |
41 |
work_a.commit('add file') |
|
5809.3.3
by Aaron Bentley
Test directories. |
42 |
tree_a = self.workingtree_to_test_tree(work_a) |
43 |
export(tree_a, 'output', 'tar') |
|
44 |
tf = tarfile.open('output') |
|
45 |
names = tf.getnames() |
|
46 |
self.assertIn('output/file', names) |
|
47 |
self.assertIn('output/dir', names) |