~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/blackbox/versioning.py

[merge] robertc's integration, updated tests to check for retcode=3

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
from bzrlib.selftest import BzrTestBase, TestCaseInTempDir
26
26
from bzrlib.branch import Branch
27
 
 
28
 
import logging
29
 
logger = logging.getLogger('bzr.test.versioning')
30
 
debug = logger.debug
 
27
from bzrlib.trace import mutter
31
28
 
32
29
 
33
30
class TestVersioning(TestCaseInTempDir):
39
36
        self.run_bzr('mkdir', 'foo')
40
37
        self.assert_(os.path.isdir('foo'))
41
38
 
42
 
        self.run_bzr('mkdir', 'foo', retcode=2)
 
39
        self.run_bzr('mkdir', 'foo', retcode=3)
43
40
 
44
41
        from bzrlib.diff import compare_trees
45
42
        from bzrlib.branch import Branch
53
50
        self.assertEquals(delta.added[0][0], 'foo')
54
51
        self.failIf(delta.modified)
55
52
 
 
53
    def test_mkdir_in_subdir(self):
 
54
        """'bzr mkdir' operation in subdirectory"""
 
55
 
 
56
        self.run_bzr('init')
 
57
        self.run_bzr('mkdir', 'dir')
 
58
        self.assert_(os.path.isdir('dir'))
 
59
 
 
60
        os.chdir('dir')
 
61
        self.log('Run mkdir in subdir')
 
62
        self.run_bzr('mkdir', 'subdir')
 
63
        self.assert_(os.path.isdir('subdir'))
 
64
        os.chdir('..')
 
65
 
 
66
        from bzrlib.diff import compare_trees
 
67
        from bzrlib.branch import Branch
 
68
        b = Branch.open('.')
 
69
        
 
70
        delta = compare_trees(b.basis_tree(), b.working_tree())
 
71
 
 
72
        self.log('delta.added = %r' % delta.added)
 
73
 
 
74
        self.assertEquals(len(delta.added), 2)
 
75
        self.assertEquals(delta.added[0][0], 'dir')
 
76
        self.assertEquals(delta.added[1][0], os.path.join('dir','subdir'))
 
77
        self.failIf(delta.modified)
 
78
 
 
79
    def test_mkdir_w_nested_trees(self):
 
80
        """'bzr mkdir' with nested trees"""
 
81
 
 
82
        self.run_bzr('init')
 
83
        os.mkdir('a')
 
84
        os.chdir('a')
 
85
        self.run_bzr('init')
 
86
        os.mkdir('b')
 
87
        os.chdir('b')
 
88
        self.run_bzr('init')
 
89
        os.chdir('../..')
 
90
 
 
91
        self.run_bzr('mkdir', 'dir', 'a/dir', 'a/b/dir')
 
92
        self.failUnless(os.path.isdir('dir'))
 
93
        self.failUnless(os.path.isdir('a/dir'))
 
94
        self.failUnless(os.path.isdir('a/b/dir'))
 
95
 
 
96
        from bzrlib.diff import compare_trees
 
97
        b = Branch.open('.')
 
98
        b_a = Branch.open('a')
 
99
        b_b = Branch.open('a/b')
 
100
        
 
101
        delta = compare_trees(b.basis_tree(), b.working_tree())
 
102
        self.assertEquals(len(delta.added), 1)
 
103
        self.assertEquals(delta.added[0][0], 'dir')
 
104
        self.failIf(delta.modified)
 
105
 
 
106
        delta = compare_trees(b_a.basis_tree(), b_a.working_tree())
 
107
        self.assertEquals(len(delta.added), 1)
 
108
        self.assertEquals(delta.added[0][0], 'dir')
 
109
        self.failIf(delta.modified)
 
110
 
 
111
        delta = compare_trees(b_b.basis_tree(), b_b.working_tree())
 
112
        self.assertEquals(len(delta.added), 1)
 
113
        self.assertEquals(delta.added[0][0], 'dir')
 
114
        self.failIf(delta.modified)
 
115
 
56
116
    def test_branch_add_in_unversioned(self):
57
117
        """Try to add a file in an unversioned directory.
58
118
 
155
215
 
156
216
        The upgrade should be a no-op."""
157
217
        b = Branch.open('.')
158
 
        debug('branch has %d revisions', b.revno())
 
218
        mutter('branch has %d revisions', b.revno())
159
219
        
160
 
        debug('check branch...')
 
220
        mutter('check branch...')
161
221
        from bzrlib.check import check
162
222
        check(b, False)
163
 
        
164
 
 
165
 
        
 
223
 
 
224
 
166
225
class SubdirCommit(TestCaseInTempDir):
167
226
 
168
227
    def test_subdir_commit(self):
184
243
        for fn in ('a/one', 'b/two', 'top'):
185
244
            file(fn, 'w').write('new contents')
186
245
            
187
 
        debug('start selective subdir commit')
 
246
        mutter('start selective subdir commit')
188
247
        run_bzr('commit', 'a', '-m', 'commit a only')
189
248
        
190
249
        old = b.revision_tree(b.get_rev_id(1))