~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_uncommit.py

  • Committer: Robert Collins
  • Date: 2006-03-01 03:26:23 UTC
  • mto: (1594.2.4 integration)
  • mto: This revision was merged to the branch mainline in revision 1596.
  • Revision ID: robertc@robertcollins.net-20060301032623-9d3c073e102f2239
Move WeaveStore down into bzrlib.store.versioned.weave.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""\
 
2
Test the uncommit command.
 
3
"""
 
4
 
 
5
import os
 
6
 
 
7
from bzrlib.errors import BzrError
 
8
from bzrlib.tests import TestCaseInTempDir
 
9
 
 
10
class TestUncommit(TestCaseInTempDir):
 
11
    def test_uncommit(self):
 
12
        """Test uncommit functionality."""
 
13
        bzr = self.capture 
 
14
        os.mkdir('branch')
 
15
        os.chdir('branch')
 
16
        bzr('init')
 
17
        self.build_tree(['a', 'b', 'c'])
 
18
 
 
19
        bzr('add')
 
20
        bzr('commit -m initial')
 
21
 
 
22
        self.assertEquals(bzr('revno'), '1\n')
 
23
 
 
24
        open('a', 'wb').write('new contents of a\n')
 
25
        self.assertEquals(bzr('status'), 'modified:\n  a\n')
 
26
        bzr('commit -m second')
 
27
 
 
28
        self.assertEquals(bzr('status'), '')
 
29
        self.assertEquals(bzr('revno'), '2\n')
 
30
 
 
31
        txt = bzr('uncommit --dry-run --force')
 
32
        self.failIfEqual(txt.find('Dry-run'), -1)
 
33
 
 
34
        self.assertEquals(bzr('status'), '')
 
35
        self.assertEquals(bzr('revno'), '2\n')
 
36
 
 
37
        txt = bzr('uncommit --force')
 
38
 
 
39
        self.assertEquals(bzr('revno'), '1\n')
 
40
        self.assertEquals(bzr('status'), 'modified:\n  a\n')
 
41
        
 
42
        bzr('checkout . ../checkout')
 
43
        os.chdir('../checkout')
 
44
        self.assertEquals("", bzr('status'))
 
45
        self.assertEquals(bzr('revno'), '1\n')
 
46
 
 
47
        open('a', 'wb').write('new contents of a\n')
 
48
        self.assertEquals(bzr('status'), 'modified:\n  a\n')
 
49
        bzr('commit -m second')
 
50
 
 
51
        self.assertEquals(bzr('status'), '')
 
52
        self.assertEquals(bzr('revno'), '2\n')
 
53
 
 
54
        txt = bzr('uncommit --dry-run --force')
 
55
        self.failIfEqual(txt.find('Dry-run'), -1)
 
56
 
 
57
        self.assertEquals(bzr('status'), '')
 
58
        self.assertEquals(bzr('revno'), '2\n')
 
59
 
 
60
        txt = bzr('uncommit --force')
 
61
 
 
62
        self.assertEquals(bzr('revno'), '1\n')
 
63
        self.assertEquals(bzr('status'), 'modified:\n  a\n')