~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_commit.py

  • Committer: Robert Collins
  • Date: 2005-10-18 13:11:57 UTC
  • mfrom: (1185.16.72) (0.2.1)
  • Revision ID: robertc@robertcollins.net-20051018131157-76a9970aa78e927e
Merged Martin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from bzrlib.selftest import TestCaseInTempDir
21
21
from bzrlib.branch import Branch
 
22
from bzrlib.workingtree import WorkingTree
22
23
from bzrlib.commit import Commit
23
24
from bzrlib.config import BranchConfig
24
25
from bzrlib.errors import PointlessCommit, BzrError, SigningFailed
213
214
 
214
215
        
215
216
    def test_removed_commit(self):
216
 
        """Test a commit with a removed file"""
 
217
        """Commit with a removed file"""
217
218
        b = Branch.initialize('.')
 
219
        wt = b.working_tree()
218
220
        file('hello', 'w').write('hello world')
219
221
        b.add(['hello'], ['hello-id'])
220
222
        b.commit(message='add hello')
221
223
 
222
 
        b.working_tree().remove('hello')
 
224
        wt = b.working_tree()  # FIXME: kludge for aliasing of working inventory
 
225
        wt.remove('hello')
223
226
        b.commit('removed hello', rev_id='rev2')
224
227
 
225
228
        tree = b.revision_tree('rev2')
256
259
        # FIXME: This should raise a KeyError I think, rbc20051006
257
260
        self.assertRaises(BzrError, inv.__getitem__, 'file2id')
258
261
 
 
262
    def test_strict_commit(self):
 
263
        """Try and commit with unknown files and strict = True, should fail."""
 
264
        from bzrlib.errors import StrictCommitFailed
 
265
        b = Branch.initialize('.')
 
266
        file('hello', 'w').write('hello world')
 
267
        b.add('hello')
 
268
        file('goodbye', 'w').write('goodbye cruel world!')
 
269
        self.assertRaises(StrictCommitFailed, b.commit,
 
270
            message='add hello but not goodbye', strict=True)
 
271
 
 
272
    def test_nonstrict_commit(self):
 
273
        """Try and commit with unknown files and strict = False, should work."""
 
274
        b = Branch.initialize('.')
 
275
        file('hello', 'w').write('hello world')
 
276
        b.add('hello')
 
277
        file('goodbye', 'w').write('goodbye cruel world!')
 
278
        b.commit(message='add hello but not goodbye', strict=False)
 
279
 
259
280
    def test_signed_commit(self):
260
281
        import bzrlib.gpg
261
282
        import bzrlib.commit as commit
297
318
            self.failIf(branch.revision_store.has_id('B'))
298
319
        finally:
299
320
            bzrlib.gpg.GPGStrategy = oldstrategy
300
 
 
301