1
# Copyright (C) 2005-2011 Canonical Ltd
1
# Copyright (C) 2005-2011, 2016 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
98
99
sorted(ball.getnames()))
100
101
def test_tar_export_unicode_filename(self):
101
self.requireFeature(tests.UnicodeFilenameFeature)
102
self.requireFeature(features.UnicodeFilenameFeature)
102
103
tree = self.make_branch_and_tree('tar')
103
104
# FIXME: using fname = u'\xe5.txt' below triggers a bug revealed since
104
105
# bzr.dev revno 4216 but more related to OSX/working trees/unicode than
117
118
def test_tar_export_unicode_basedir(self):
118
119
"""Test for bug #413406"""
119
self.requireFeature(tests.UnicodeFilenameFeature)
120
self.requireFeature(features.UnicodeFilenameFeature)
120
121
basedir = u'\N{euro sign}'
121
122
os.mkdir(basedir)
122
123
self.run_bzr(['init', basedir])
191
192
def test_tbz2_export(self):
192
193
self.run_tar_export_disk_and_stdout('tbz2', 'bz2')
194
# TODO: test_xz_export, I don't have pylzma working here to test it.
196
195
def test_zip_export_unicode(self):
197
self.requireFeature(tests.UnicodeFilenameFeature)
196
self.requireFeature(features.UnicodeFilenameFeature)
198
197
tree = self.make_branch_and_tree('zip')
199
198
fname = u'\N{Euro Sign}.txt'
200
199
self.build_tree(['zip/' + fname])
385
384
tree.commit('setup', timestamp=315532800)
386
385
self.run_bzr('export --per-file-timestamps t branch')
387
386
har_st = os.stat('t/har')
388
self.assertEquals(315532800, har_st.st_mtime)
387
self.assertEqual(315532800, har_st.st_mtime)
390
389
def test_dir_export_partial_tree_per_file_timestamps(self):
391
390
tree = self.example_branch()
395
394
tree.commit('setup', timestamp=315532800)
396
395
self.run_bzr('export --per-file-timestamps tpart branch/subdir')
397
396
foo_st = os.stat('tpart/foo.txt')
398
self.assertEquals(315532800, foo_st.st_mtime)
397
self.assertEqual(315532800, foo_st.st_mtime)
400
399
def test_export_directory(self):
401
400
"""Test --directory option"""
404
403
self.assertEqual(['goodbye', 'hello'], sorted(os.listdir('latest')))
405
404
self.check_file_contents('latest/goodbye', 'baz')
406
def test_export_uncommitted(self):
407
"""Test --uncommitted option"""
408
self.example_branch()
410
self.build_tree_contents([('goodbye', 'uncommitted data')])
411
self.run_bzr(['export', '--uncommitted', 'latest'])
412
self.check_file_contents('latest/goodbye', 'uncommitted data')
414
def test_export_uncommitted_no_tree(self):
415
"""Test --uncommitted option only works with a working tree."""
416
tree = self.example_branch()
417
tree.bzrdir.destroy_workingtree()
420
['bzr: ERROR: --uncommitted requires a working tree'],
421
'export --uncommitted latest')
407
423
def test_zip_export_per_file_timestamps(self):
408
424
tree = self.example_branch()
409
425
self.build_tree_contents([('branch/har', 'foo')])
414
430
self.run_bzr('export --per-file-timestamps test.zip branch')
415
431
zfile = zipfile.ZipFile('test.zip')
416
432
info = zfile.getinfo("test/har")
417
self.assertEquals(time.localtime(timestamp)[:6], info.date_time)
433
self.assertEqual(time.localtime(timestamp)[:6], info.date_time)
436
class TestSmartServerExport(TestCaseWithTransport):
438
def test_simple_export(self):
439
self.setup_smart_server_with_call_log()
440
t = self.make_branch_and_tree('branch')
441
self.build_tree_contents([('branch/foo', 'thecontents')])
444
self.reset_smart_call_log()
445
out, err = self.run_bzr(['export', "foo.tar.gz", self.get_url('branch')])
446
# This figure represent the amount of work to perform this use case. It
447
# is entirely ok to reduce this number if a test fails due to rpc_count
448
# being too low. If rpc_count increases, more network roundtrips have
449
# become necessary for this use case. Please do not adjust this number
450
# upwards without agreement from bzr's network support maintainers.
451
self.assertLength(7, self.hpss_calls)
452
self.assertLength(1, self.hpss_connections)
453
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)