1
# Copyright (C) 2005, 2006, 2007, 2009, 2010 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2007, 2009-2012 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
41
41
self.run_bzr(['mkdir', 'abc'], retcode=3)
42
42
self.assertPathDoesNotExist('abc')
45
class TestVersioning(TestCaseInTempDir):
47
44
def test_mkdir(self):
48
45
"""Basic 'bzr mkdir' operation"""
47
self.make_branch_and_tree('.')
51
48
self.run_bzr(['mkdir', 'foo'])
52
49
self.assert_(os.path.isdir('foo'))
66
63
def test_mkdir_in_subdir(self):
67
64
"""'bzr mkdir' operation in subdirectory"""
66
self.make_branch_and_tree('.')
70
67
self.run_bzr(['mkdir', 'dir'])
71
68
self.assert_(os.path.isdir('dir'))
74
70
self.log('Run mkdir in subdir')
75
self.run_bzr(['mkdir', 'subdir'])
76
self.assert_(os.path.isdir('subdir'))
71
self.run_bzr(['mkdir', 'subdir'], working_dir='dir')
72
self.assert_(os.path.isdir('dir/subdir'))
79
74
wt = WorkingTree.open('.')
90
85
def test_mkdir_w_nested_trees(self):
91
86
"""'bzr mkdir' with nested trees"""
88
self.make_branch_and_tree('.')
89
self.make_branch_and_tree('a')
90
self.make_branch_and_tree('a/b')
102
92
self.run_bzr(['mkdir', 'dir', 'a/dir', 'a/b/dir'])
103
93
self.assertTrue(os.path.isdir('dir'))
123
113
self.assertEquals(delta.added[0][0], 'dir')
124
114
self.assertFalse(delta.modified)
126
def check_branch(self):
127
"""After all the above changes, run the check and upgrade commands.
129
The upgrade should be a no-op."""
130
b = Branch.open(u'.')
131
mutter('branch has %d revisions', b.revno())
133
mutter('check branch...')
134
from bzrlib.check import check
116
def test_mkdir_quiet(self):
117
"""'bzr mkdir --quiet' should not print a status message"""
119
self.make_branch_and_tree('.')
120
out, err = self.run_bzr(['mkdir', '--quiet', 'foo'])
121
self.assertEquals('', err)
122
self.assertEquals('', out)
138
125
class SubdirCommit(TestCaseWithTransport):
159
146
new = b.repository.revision_tree(b.get_rev_id(2))
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')
149
def get_text_by_path(tree, path):
150
return tree.get_file_text(tree.path2id(path), path)
152
self.assertEqual(get_text_by_path(new, 'b/two'), 'old contents')
153
self.assertEqual(get_text_by_path(new, 'top'), 'old contents')
154
self.assertEqual(get_text_by_path(new, 'a/one'), 'new contents')
168
157
# commit from here should do nothing
169
self.run_bzr(['commit', '.', '-m', 'commit subdir only', '--unchanged'])
158
self.run_bzr(['commit', '.', '-m', 'commit subdir only', '--unchanged'],
170
160
v3 = b.repository.revision_tree(b.get_rev_id(3))
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')
162
self.assertEqual(get_text_by_path(v3, 'b/two'), 'old contents')
163
self.assertEqual(get_text_by_path(v3, 'top'), 'old contents')
164
self.assertEqual(get_text_by_path(v3, 'a/one'), 'new contents')
177
167
# commit in subdirectory commits whole tree
178
self.run_bzr(['commit', '-m', 'commit whole tree from subdir'])
168
self.run_bzr(['commit', '-m', 'commit whole tree from subdir'],
179
170
v4 = b.repository.revision_tree(b.get_rev_id(4))
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')
172
self.assertEqual(get_text_by_path(v4, 'b/two'), 'new contents')
173
self.assertEqual(get_text_by_path(v4, 'top'), 'new contents')
185
176
# TODO: factor out some kind of assert_tree_state() method