~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_uncommit.py

Add Transport.supports_unix_modebits, so tests can 
avoid testing them where they won't work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
"""\
2
2
Test the uncommit command.
3
3
"""
 
4
 
 
5
import os
 
6
 
 
7
from bzrlib.bzrdir import BzrDirMetaFormat1
 
8
from bzrlib.errors import BzrError, BoundBranchOutOfDate
 
9
from bzrlib.uncommit import uncommit
4
10
from bzrlib.tests import TestCaseInTempDir
5
 
from bzrlib.errors import BzrError
6
11
 
7
12
class TestUncommit(TestCaseInTempDir):
8
13
    def test_uncommit(self):
9
14
        """Test uncommit functionality."""
10
15
        bzr = self.capture 
11
 
 
 
16
        os.mkdir('branch')
 
17
        os.chdir('branch')
12
18
        bzr('init')
13
19
        self.build_tree(['a', 'b', 'c'])
14
20
 
34
40
 
35
41
        self.assertEquals(bzr('revno'), '1\n')
36
42
        self.assertEquals(bzr('status'), 'modified:\n  a\n')
 
43
        
 
44
        bzr('checkout . ../checkout')
 
45
        os.chdir('../checkout')
 
46
        self.assertEquals("", bzr('status'))
 
47
        self.assertEquals(bzr('revno'), '1\n')
 
48
 
 
49
        open('a', 'wb').write('new contents of a\n')
 
50
        self.assertEquals(bzr('status'), 'modified:\n  a\n')
 
51
        bzr('commit -m second')
 
52
 
 
53
        self.assertEquals(bzr('status'), '')
 
54
        self.assertEquals(bzr('revno'), '2\n')
 
55
 
 
56
        txt = bzr('uncommit --dry-run --force')
 
57
        self.failIfEqual(txt.find('Dry-run'), -1)
 
58
 
 
59
        self.assertEquals(bzr('status'), '')
 
60
        self.assertEquals(bzr('revno'), '2\n')
 
61
 
 
62
        txt = bzr('uncommit --force')
 
63
 
 
64
        self.assertEquals(bzr('revno'), '1\n')
 
65
        self.assertEquals(bzr('status'), 'modified:\n  a\n')
 
66
 
 
67
    def test_uncommit_bound(self):
 
68
        os.mkdir('a')
 
69
        a = BzrDirMetaFormat1().initialize('a')
 
70
        a.create_repository()
 
71
        a.create_branch()
 
72
        t = a.create_workingtree()
 
73
        t.commit('commit 1')
 
74
        t.commit('commit 2')
 
75
        t.commit('commit 3')
 
76
        b = t.bzrdir.sprout('b').open_branch()
 
77
        b.bind(t.branch)
 
78
        uncommit(b)
 
79
        t.set_last_revision(t.branch.last_revision())
 
80
        self.assertEqual(len(b.revision_history()), 2)
 
81
        self.assertEqual(len(t.branch.revision_history()), 2)
 
82
        t.commit('commit 3b')
 
83
        self.assertRaises(BoundBranchOutOfDate, uncommit, b)
 
84
        b.pull(t.branch)
 
85
        uncommit(b)
37
86