~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_commit.py

  • Committer: Martin Pool
  • Date: 2005-09-15 05:35:33 UTC
  • Revision ID: mbp@sourcefrog.net-20050915053532-fdd525fa04e9fbc5
- test that pointless commits are trapped

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
        self.assertFalse(tree.has_id('hello-id'))
64
64
 
65
65
 
 
66
    def test_pointless_commit(self):
 
67
        """Commit refuses unless there are changes or it's forced."""
 
68
        b = Branch('.', init=True)
 
69
        file('hello', 'w').write('hello')
 
70
        b.add(['hello'])
 
71
        b.commit(message='add hello')
 
72
        self.assertEquals(b.revno(), 1)
 
73
        self.assertRaises(PointlessCommit,
 
74
                          b.commit,
 
75
                          message='fails',
 
76
                          allow_pointless=False)
 
77
        self.assertEquals(b.revno(), 1)
 
78
        
 
79
 
 
80
 
66
81
    def test_commit_empty(self):
 
82
        """Commiting an empty tree works."""
67
83
        b = Branch('.', init=True)
68
84
        b.commit(message='empty tree', allow_pointless=True)
69
 
        ##self.assertRaises(PointlessCommit,
70
 
        ##                  b.commit,
71
 
        ##                  message='empty tree')
 
85
        self.assertRaises(PointlessCommit,
 
86
                          b.commit,
 
87
                          message='empty tree',
 
88
                          allow_pointless=False)
72
89
        b.commit(message='empty tree', allow_pointless=True)
73
90
        self.assertEquals(b.revno(), 2)
74
91