/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/selftest/versioning.py

  • Committer: Martin Pool
  • Date: 2005-09-22 12:12:53 UTC
  • Revision ID: mbp@sourcefrog.net-20050922121253-eae2a3240ea5e493
- upgrade can no longer be done in current version branches
  so don't test it

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
 
24
24
import os
25
 
from bzrlib.selftest import InTempDir, BzrTestBase
 
25
 
 
26
from bzrlib.selftest import BzrTestBase, TestCaseInTempDir
26
27
from bzrlib.branch import Branch
27
28
 
28
 
 
29
 
class Mkdir(InTempDir):
30
 
    def runTest(self): 
 
29
import logging
 
30
logger = logging.getLogger('bzr.test.versioning')
 
31
debug = logger.debug
 
32
 
 
33
 
 
34
class TestVersioning(TestCaseInTempDir):
 
35
    
 
36
    def test_mkdir(self): 
31
37
        """Basic 'bzr mkdir' operation"""
32
38
        from bzrlib.commands import run_bzr
33
39
 
49
55
        self.assertEquals(delta.added[0][0], 'foo')
50
56
        self.failIf(delta.modified)
51
57
 
52
 
 
53
 
 
54
 
class AddInUnversioned(InTempDir):
55
 
    def runTest(self):
 
58
    def test_add_in_unversioned(self):
56
59
        """Try to add a file in an unversioned directory.
57
60
 
58
61
        smart_add may eventually add the parent as necessary, but simple
70
73
                          b.add,
71
74
                          'foo/hello')
72
75
        
73
 
        
74
 
class SubdirCommit(BzrTestBase):
75
 
    def runTest(self):
 
76
        self.check_branch()
 
77
 
 
78
        
 
79
    def test_subdir_add(self):
 
80
        """Add in subdirectory should add only things from there down"""
 
81
        
 
82
        from bzrlib.branch import Branch
 
83
        from bzrlib.commands import run_bzr
 
84
        
 
85
        eq = self.assertEqual
 
86
        ass = self.assert_
 
87
        chdir = os.chdir
 
88
        
 
89
        b = Branch('.', init=True)
 
90
        self.build_tree(['src/', 'README'])
 
91
        
 
92
        eq(sorted(b.unknowns()),
 
93
           ['README', 'src'])
 
94
        
 
95
        eq(run_bzr(['add', 'src']), 0)
 
96
        
 
97
        self.build_tree(['src/foo.c'])
 
98
        
 
99
        chdir('src')
 
100
        eq(run_bzr(['add']), 0)
 
101
        
 
102
        eq(sorted(b.unknowns()), 
 
103
           ['README'])
 
104
        eq(len(b.inventory), 3)
 
105
                
 
106
        chdir('..')
 
107
        eq(run_bzr(['add']), 0)
 
108
        eq(list(b.unknowns()), [])
 
109
 
 
110
        self.check_branch()
 
111
 
 
112
 
 
113
    def check_branch(self):
 
114
        """After all the above changes, run the check and upgrade commands.
 
115
 
 
116
        The upgrade should be a no-op."""
 
117
        b = Branch('.')
 
118
        debug('branch has %d revisions', b.revno())
 
119
        
 
120
        debug('check branch...')
 
121
        from bzrlib.check import check
 
122
        check(b)
 
123
        
 
124
 
 
125
        
 
126
        
 
127
class SubdirCommit(TestCaseInTempDir):
 
128
 
 
129
    def test_subdir_commit(self):
76
130
        """Test committing a subdirectory, and committing within a directory."""
77
131
        run_bzr = self.run_bzr
78
132
        eq = self.assertEqual
91
145
        for fn in ('a/one', 'b/two', 'top'):
92
146
            file(fn, 'w').write('new contents')
93
147
            
 
148
        debug('start selective subdir commit')
94
149
        run_bzr('commit', 'a', '-m', 'commit a only')
95
150
        
96
151
        old = b.revision_tree(b.lookup_revision(1))
116
171
        
117
172
        # TODO: factor out some kind of assert_tree_state() method
118
173
        
119
 
        
120
 
        
121
 
class SubdirAdd(InTempDir):
122
 
    def runTest(self):
123
 
        """Add in subdirectory should add only things from there down"""
124
 
        
125
 
        from bzrlib.branch import Branch
126
 
        from bzrlib.commands import run_bzr
127
 
        
128
 
        eq = self.assertEqual
129
 
        ass = self.assert_
130
 
        chdir = os.chdir
131
 
        
132
 
        b = Branch('.', init=True)
133
 
        self.build_tree(['src/', 'README'])
134
 
        
135
 
        eq(sorted(b.unknowns()),
136
 
           ['README', 'src'])
137
 
        
138
 
        eq(run_bzr(['add', 'src']), 0)
139
 
        
140
 
        self.build_tree(['src/foo.c'])
141
 
        
142
 
        chdir('src')
143
 
        eq(run_bzr(['add']), 0)
144
 
        
145
 
        eq(sorted(b.unknowns()), 
146
 
           ['README'])
147
 
        eq(len(b.inventory), 3)
148
 
                
149
 
        chdir('..')
150
 
        eq(run_bzr(['add']), 0)
151
 
        eq(list(b.unknowns()), [])
152
 
        
 
174
 
 
175
if __name__ == '__main__':
 
176
    import unittest
 
177
    unittest.main()
 
178