~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_export.py

  • Committer: Jelmer Vernooij
  • Date: 2011-05-16 13:39:39 UTC
  • mto: (5923.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 5925.
  • Revision ID: jelmer@samba.org-20110516133939-8u1pc9utas3uw1lt
Require a unicode prompt to be passed into all methods that prompt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    tests,
29
29
    )
30
30
from bzrlib.export import get_root_name
31
 
from bzrlib.export.tar_exporter import export_tarball_generator
 
31
from bzrlib.export.tar_exporter import export_tarball
32
32
from bzrlib.tests import features
33
33
 
34
34
 
84
84
        wt.add(['a', 'b', 'b/c'])
85
85
        wt.commit('1')
86
86
        self.build_tree(['target/', 'target/foo'])
87
 
        self.assertRaises(errors.BzrError,
88
 
            export.export, wt, 'target', format="dir")
 
87
        self.assertRaises(errors.BzrError, export.export, wt, 'target', format="dir")
89
88
 
90
89
    def test_existing_single_file(self):
91
 
        self.build_tree([
92
 
            'dir1/', 'dir1/dir2/', 'dir1/first', 'dir1/dir2/second'])
 
90
        self.build_tree(['dir1/', 'dir1/dir2/', 'dir1/first', 'dir1/dir2/second'])
93
91
        wtree = self.make_branch_and_tree('dir1')
94
92
        wtree.add(['dir2', 'first', 'dir2/second'])
95
93
        wtree.commit('1')
112
110
        self.addCleanup(b.unlock)
113
111
        tree = b.basis_tree()
114
112
        orig_iter_files_bytes = tree.iter_files_bytes
115
 
 
116
113
        # Make iter_files_bytes slower, so we provoke mtime skew
117
114
        def iter_files_bytes(to_fetch):
118
115
            for thing in orig_iter_files_bytes(to_fetch):
149
146
        self.assertEqual(a_time, t.stat('a').st_mtime)
150
147
        self.assertEqual(b_time, t.stat('b').st_mtime)
151
148
 
152
 
    def test_subdir_files_per_timestamps(self):
153
 
        builder = self.make_branch_builder('source')
154
 
        builder.start_series()
155
 
        foo_time = time.mktime((1999, 12, 12, 0, 0, 0, 0, 0, 0))
156
 
        builder.build_snapshot(None, None, [
157
 
            ('add', ('', 'root-id', 'directory', '')),
158
 
            ('add', ('subdir', 'subdir-id', 'directory', '')),
159
 
            ('add', ('subdir/foo.txt', 'foo-id', 'file', 'content\n'))],
160
 
            timestamp=foo_time)
161
 
        builder.finish_series()
162
 
        b = builder.get_branch()
163
 
        b.lock_read()
164
 
        self.addCleanup(b.unlock)
165
 
        tree = b.basis_tree()
166
 
        export.export(tree, 'target', format='dir', subdir='subdir',
167
 
            per_file_timestamps=True)
168
 
        t = self.get_transport('target')
169
 
        self.assertEquals(foo_time, t.stat('foo.txt').st_mtime)
170
 
 
171
149
 
172
150
class TarExporterTests(tests.TestCaseWithTransport):
173
151
 
242
220
        self.assertRaises(errors.BzrError, export.export, wt, '-',
243
221
            format="txz")
244
222
 
245
 
    def test_export_tarball_generator(self):
 
223
    def test_export_tarball(self):
246
224
        wt = self.make_branch_and_tree('.')
247
225
        self.build_tree(['a'])
248
226
        wt.add(["a"])
251
229
        ball = tarfile.open(None, "w|", target)
252
230
        wt.lock_read()
253
231
        try:
254
 
            for _ in export_tarball_generator(wt, ball, "bar"):
255
 
                pass
 
232
            export_tarball(wt, ball, "bar")
256
233
        finally:
257
234
            wt.unlock()
258
 
        # Ball should now be closed.
259
 
        target.seek(0)
260
 
        ball2 = tarfile.open(None, "r", target)
261
 
        self.addCleanup(ball2.close)
262
 
        self.assertEquals(["bar/a"], ball2.getnames())
 
235
        self.assertEquals(["bar/a"], ball.getnames())
 
236
        ball.close()
263
237
 
264
238
 
265
239
class ZipExporterTests(tests.TestCaseWithTransport):