~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/versioning.py

  • Committer: John Arbash Meinel
  • Date: 2005-09-15 21:35:53 UTC
  • mfrom: (907.1.57)
  • mto: (1393.2.1)
  • mto: This revision was merged to the branch mainline in revision 1396.
  • Revision ID: john@arbash-meinel.com-20050915213552-a6c83a5ef1e20897
(broken) Transport work is merged in. Tests do not pass yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
        from bzrlib.diff import compare_trees
46
46
        from bzrlib.branch import Branch
47
 
        b = Branch.open('.')
 
47
        b = Branch('.')
48
48
        
49
49
        delta = compare_trees(b.basis_tree(), b.working_tree())
50
50
 
63
63
        from bzrlib.branch import Branch
64
64
        from bzrlib.errors import NotVersionedError
65
65
 
66
 
        b = Branch.initialize('.')
 
66
        b = Branch('.', init=True)
67
67
 
68
68
        self.build_tree(['foo/',
69
69
                         'foo/hello'])
72
72
                          b.add,
73
73
                          'foo/hello')
74
74
        
75
 
        self.check_branch()
 
75
        self.check_and_upgrade()
76
76
 
77
77
 
78
78
    def test_add_in_unversioned(self):
84
84
        from bzrlib.commands import run_bzr
85
85
        eq = self.assertEqual
86
86
 
87
 
        b = Branch.initialize('.')
 
87
        b = Branch('.', init=True)
88
88
 
89
89
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
90
90
        eq(list(b.unknowns()), ['inertiatic'])
112
112
        from bzrlib.commands import run_bzr
113
113
        eq = self.assertEqual
114
114
 
115
 
        b = Branch.initialize('.')
 
115
        b = Branch('.', init=True)
116
116
 
117
117
        self.build_tree(['inertiatic/', 'inertiatic/esp'])
118
118
        eq(list(b.unknowns()), ['inertiatic'])
119
119
        run_bzr(['add', '--no-recurse', 'inertiatic'])
120
 
        eq(list(b.unknowns()), ['inertiatic'+os.sep+'esp'])
 
120
        eq(list(b.unknowns()), ['inertiatic/esp'])
121
121
        run_bzr(['add', 'inertiatic/esp'])
122
122
        eq(list(b.unknowns()), [])
123
123
 
131
131
        ass = self.assert_
132
132
        chdir = os.chdir
133
133
        
134
 
        b = Branch.initialize('.')
 
134
        b = Branch('.', init=True)
135
135
        self.build_tree(['src/', 'README'])
136
136
        
137
137
        eq(sorted(b.unknowns()),
152
152
        eq(run_bzr(['add']), 0)
153
153
        eq(list(b.unknowns()), [])
154
154
 
155
 
        self.check_branch()
156
 
 
157
 
 
158
 
    def check_branch(self):
 
155
        self.check_and_upgrade()
 
156
 
 
157
 
 
158
    def check_and_upgrade(self):
159
159
        """After all the above changes, run the check and upgrade commands.
160
160
 
161
161
        The upgrade should be a no-op."""
162
 
        b = Branch.open('.')
 
162
        b = Branch('.')
163
163
        debug('branch has %d revisions', b.revno())
164
164
        
165
165
        debug('check branch...')
166
166
        from bzrlib.check import check
167
167
        check(b)
168
168
        
 
169
        debug('upgrade branch...')
 
170
        from bzrlib.upgrade import upgrade
 
171
        upgrade(b)
 
172
        
 
173
        debug('check branch...')
 
174
        from bzrlib.check import check
 
175
        check(b)
 
176
        
169
177
 
170
178
        
171
179
class SubdirCommit(TestCaseInTempDir):
178
186
        self.build_tree(['a/', 'b/'])
179
187
        
180
188
        run_bzr('init')
181
 
        b = Branch.open('.')
 
189
        b = Branch('.')
182
190
        
183
191
        for fn in ('a/one', 'b/two', 'top'):
184
192
            file(fn, 'w').write('old contents')
189
197
        for fn in ('a/one', 'b/two', 'top'):
190
198
            file(fn, 'w').write('new contents')
191
199
            
192
 
        debug('start selective subdir commit')
193
200
        run_bzr('commit', 'a', '-m', 'commit a only')
194
201
        
195
 
        old = b.revision_tree(b.get_rev_id(1))
196
 
        new = b.revision_tree(b.get_rev_id(2))
 
202
        old = b.revision_tree(b.lookup_revision(1))
 
203
        new = b.revision_tree(b.lookup_revision(2))
197
204
        
198
205
        eq(new.get_file_by_path('b/two').read(), 'old contents')
199
206
        eq(new.get_file_by_path('top').read(), 'old contents')
202
209
        os.chdir('a')
203
210
        # commit from here should do nothing
204
211
        run_bzr('commit', '.', '-m', 'commit subdir only', '--unchanged')
205
 
        v3 = b.revision_tree(b.get_rev_id(3))
 
212
        v3 = b.revision_tree(b.lookup_revision(3))
206
213
        eq(v3.get_file_by_path('b/two').read(), 'old contents')
207
214
        eq(v3.get_file_by_path('top').read(), 'old contents')
208
215
        eq(v3.get_file_by_path('a/one').read(), 'new contents')
209
216
                
210
217
        # commit in subdirectory commits whole tree
211
218
        run_bzr('commit', '-m', 'commit whole tree from subdir')
212
 
        v4 = b.revision_tree(b.get_rev_id(4))
 
219
        v4 = b.revision_tree(b.lookup_revision(4))
213
220
        eq(v4.get_file_by_path('b/two').read(), 'new contents')        
214
221
        eq(v4.get_file_by_path('top').read(), 'new contents')
215
222
        
216
223
        # TODO: factor out some kind of assert_tree_state() method
217
224
        
218
 
 
219
 
if __name__ == '__main__':
220
 
    import unittest
221
 
    unittest.main()
222