~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_export.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-06-10 10:33:31 UTC
  • mfrom: (4426.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090610103331-ht76b0l92gj1gn9d
(bialix) Start Russian translation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009 Canonical Ltd
2
2
#
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
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import os
18
 
import time
 
18
 
19
19
 
20
20
from bzrlib import (
21
 
    errors,
22
21
    export,
23
 
    osutils,
24
22
    tests,
25
23
    )
26
24
 
36
34
        self.failUnlessExists('target/a/b')
37
35
        self.failIfExists('target/a/c')
38
36
 
39
 
    def test_dir_export_symlink(self):
40
 
        self.requireFeature(tests.SymlinkFeature)
41
 
        wt = self.make_branch_and_tree('.')
42
 
        os.symlink('source', 'link')
43
 
        wt.add(['link'])
44
 
        export.export(wt, 'target', format="dir")
45
 
        self.failUnlessExists('target/link')
46
 
 
47
 
    def test_dir_export_to_existing_empty_dir_success(self):
48
 
        self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c'])
49
 
        wt = self.make_branch_and_tree('source')
50
 
        wt.add(['a', 'b', 'b/c'])
51
 
        wt.commit('1')
52
 
        self.build_tree(['target/'])
53
 
        export.export(wt, 'target', format="dir")
54
 
        self.failUnlessExists('target/a')
55
 
        self.failUnlessExists('target/b')
56
 
        self.failUnlessExists('target/b/c')
57
 
 
58
 
    def test_dir_export_to_existing_nonempty_dir_fail(self):
59
 
        self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c'])
60
 
        wt = self.make_branch_and_tree('source')
61
 
        wt.add(['a', 'b', 'b/c'])
62
 
        wt.commit('1')
63
 
        self.build_tree(['target/', 'target/foo'])
64
 
        self.assertRaises(errors.BzrError, export.export, wt, 'target', format="dir")
65
 
 
66
 
    def test_dir_export_existing_single_file(self):
67
 
        self.build_tree(['dir1/', 'dir1/dir2/', 'dir1/first', 'dir1/dir2/second'])
68
 
        wtree = self.make_branch_and_tree('dir1')
69
 
        wtree.add(['dir2', 'first', 'dir2/second'])
70
 
        wtree.commit('1')
71
 
        export.export(wtree, 'target1', format='dir', subdir='first')
72
 
        self.failUnlessExists('target1/first')
73
 
        export.export(wtree, 'target2', format='dir', subdir='dir2/second')
74
 
        self.failUnlessExists('target2/second')
75
 
        
76
 
    def test_dir_export_files_same_timestamp(self):
77
 
        builder = self.make_branch_builder('source')
78
 
        builder.start_series()
79
 
        builder.build_snapshot(None, None, [
80
 
            ('add', ('', 'root-id', 'directory', '')),
81
 
            ('add', ('a', 'a-id', 'file', 'content\n'))])
82
 
        builder.build_snapshot(None, None, [
83
 
            ('add', ('b', 'b-id', 'file', 'content\n'))])
84
 
        builder.finish_series()
85
 
        b = builder.get_branch()
86
 
        b.lock_read()
87
 
        self.addCleanup(b.unlock)
88
 
        tree = b.basis_tree()
89
 
        orig_iter_files_bytes = tree.iter_files_bytes
90
 
        # Make iter_files_bytes slower, so we provoke mtime skew
91
 
        def iter_files_bytes(to_fetch):
92
 
            for thing in orig_iter_files_bytes(to_fetch):
93
 
                yield thing
94
 
                time.sleep(1)
95
 
        tree.iter_files_bytes = iter_files_bytes
96
 
        export.export(tree, 'target', format='dir')
97
 
        t = self.get_transport('target')
98
 
        st_a = t.stat('a')
99
 
        st_b = t.stat('b')
100
 
        # All files must be given the same mtime.
101
 
        self.assertEqual(st_a.st_mtime, st_b.st_mtime)