~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_versioning.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-16 19:18:39 UTC
  • mto: This revision was merged to the branch mainline in revision 6391.
  • Revision ID: jelmer@samba.org-20111216191839-eg681lxqibi1qxu1
Fix remaining tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
        # here locally.
40
40
        shared_repo = self.make_repository('.')
41
41
        self.run_bzr(['mkdir', 'abc'], retcode=3)
42
 
        self.failIfExists('abc')
43
 
 
44
 
 
45
 
class TestVersioning(TestCaseInTempDir):
 
42
        self.assertPathDoesNotExist('abc')
46
43
 
47
44
    def test_mkdir(self):
48
45
        """Basic 'bzr mkdir' operation"""
49
46
 
50
 
        self.run_bzr('init')
 
47
        self.make_branch_and_tree('.')
51
48
        self.run_bzr(['mkdir', 'foo'])
52
49
        self.assert_(os.path.isdir('foo'))
53
50
 
61
58
 
62
59
        self.assertEquals(len(delta.added), 1)
63
60
        self.assertEquals(delta.added[0][0], 'foo')
64
 
        self.failIf(delta.modified)
 
61
        self.assertFalse(delta.modified)
65
62
 
66
63
    def test_mkdir_in_subdir(self):
67
64
        """'bzr mkdir' operation in subdirectory"""
68
65
 
69
 
        self.run_bzr('init')
 
66
        self.make_branch_and_tree('.')
70
67
        self.run_bzr(['mkdir', 'dir'])
71
68
        self.assert_(os.path.isdir('dir'))
72
69
 
85
82
        self.assertEquals(len(delta.added), 2)
86
83
        self.assertEquals(delta.added[0][0], 'dir')
87
84
        self.assertEquals(delta.added[1][0], pathjoin('dir','subdir'))
88
 
        self.failIf(delta.modified)
 
85
        self.assertFalse(delta.modified)
89
86
 
90
87
    def test_mkdir_w_nested_trees(self):
91
88
        """'bzr mkdir' with nested trees"""
92
89
 
93
 
        self.run_bzr('init')
94
 
        os.mkdir('a')
95
 
        os.chdir('a')
96
 
        self.run_bzr('init')
97
 
        os.mkdir('b')
98
 
        os.chdir('b')
99
 
        self.run_bzr('init')
100
 
        os.chdir('../..')
 
90
        self.make_branch_and_tree('.')
 
91
        self.make_branch_and_tree('a')
 
92
        self.make_branch_and_tree('a/b')
101
93
 
102
94
        self.run_bzr(['mkdir', 'dir', 'a/dir', 'a/b/dir'])
103
 
        self.failUnless(os.path.isdir('dir'))
104
 
        self.failUnless(os.path.isdir('a/dir'))
105
 
        self.failUnless(os.path.isdir('a/b/dir'))
 
95
        self.assertTrue(os.path.isdir('dir'))
 
96
        self.assertTrue(os.path.isdir('a/dir'))
 
97
        self.assertTrue(os.path.isdir('a/b/dir'))
106
98
 
107
99
        wt = WorkingTree.open('.')
108
100
        wt_a = WorkingTree.open('a')
111
103
        delta = wt.changes_from(wt.basis_tree())
112
104
        self.assertEquals(len(delta.added), 1)
113
105
        self.assertEquals(delta.added[0][0], 'dir')
114
 
        self.failIf(delta.modified)
 
106
        self.assertFalse(delta.modified)
115
107
 
116
108
        delta = wt_a.changes_from(wt_a.basis_tree())
117
109
        self.assertEquals(len(delta.added), 1)
118
110
        self.assertEquals(delta.added[0][0], 'dir')
119
 
        self.failIf(delta.modified)
 
111
        self.assertFalse(delta.modified)
120
112
 
121
113
        delta = wt_b.changes_from(wt_b.basis_tree())
122
114
        self.assertEquals(len(delta.added), 1)
123
115
        self.assertEquals(delta.added[0][0], 'dir')
124
 
        self.failIf(delta.modified)
125
 
 
126
 
    def check_branch(self):
127
 
        """After all the above changes, run the check and upgrade commands.
128
 
 
129
 
        The upgrade should be a no-op."""
130
 
        b = Branch.open(u'.')
131
 
        mutter('branch has %d revisions', b.revno())
132
 
 
133
 
        mutter('check branch...')
134
 
        from bzrlib.check import check
135
 
        check(b, False)
 
116
        self.assertFalse(delta.modified)
 
117
 
 
118
    def test_mkdir_quiet(self):
 
119
        """'bzr mkdir --quiet' should not print a status message"""
 
120
 
 
121
        self.make_branch_and_tree('.')
 
122
        out, err = self.run_bzr(['mkdir', '--quiet', 'foo'])
 
123
        self.assertEquals('', err)
 
124
        self.assertEquals('', out)
136
125
 
137
126
 
138
127
class SubdirCommit(TestCaseWithTransport):
159
148
        new = b.repository.revision_tree(b.get_rev_id(2))
160
149
        new.lock_read()
161
150
 
162
 
        self.assertEqual(new.get_file_by_path('b/two').read(), 'old contents')
163
 
        self.assertEqual(new.get_file_by_path('top').read(), 'old contents')
164
 
        self.assertEqual(new.get_file_by_path('a/one').read(), 'new contents')
 
151
        def get_text_by_path(tree, path):
 
152
            return tree.get_file_text(tree.path2id(path), path)
 
153
 
 
154
        self.assertEqual(get_text_by_path(new, 'b/two'), 'old contents')
 
155
        self.assertEqual(get_text_by_path(new, 'top'), 'old contents')
 
156
        self.assertEqual(get_text_by_path(new, 'a/one'), 'new contents')
165
157
        new.unlock()
166
158
 
167
159
        os.chdir('a')
169
161
        self.run_bzr(['commit', '.', '-m', 'commit subdir only', '--unchanged'])
170
162
        v3 = b.repository.revision_tree(b.get_rev_id(3))
171
163
        v3.lock_read()
172
 
        self.assertEqual(v3.get_file_by_path('b/two').read(), 'old contents')
173
 
        self.assertEqual(v3.get_file_by_path('top').read(), 'old contents')
174
 
        self.assertEqual(v3.get_file_by_path('a/one').read(), 'new contents')
 
164
        self.assertEqual(get_text_by_path(v3, 'b/two'), 'old contents')
 
165
        self.assertEqual(get_text_by_path(v3, 'top'), 'old contents')
 
166
        self.assertEqual(get_text_by_path(v3, 'a/one'), 'new contents')
175
167
        v3.unlock()
176
168
 
177
169
        # commit in subdirectory commits whole tree
178
170
        self.run_bzr(['commit', '-m', 'commit whole tree from subdir'])
179
171
        v4 = b.repository.revision_tree(b.get_rev_id(4))
180
172
        v4.lock_read()
181
 
        self.assertEqual(v4.get_file_by_path('b/two').read(), 'new contents')
182
 
        self.assertEqual(v4.get_file_by_path('top').read(), 'new contents')
 
173
        self.assertEqual(get_text_by_path(v4, 'b/two'), 'new contents')
 
174
        self.assertEqual(get_text_by_path(v4, 'top'), 'new contents')
183
175
        v4.unlock()
184
176
 
185
177
        # TODO: factor out some kind of assert_tree_state() method