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
67
67
self.run_bzr(['mkdir', 'dir'])
68
68
self.assert_(os.path.isdir('dir'))
71
70
self.log('Run mkdir in subdir')
72
self.run_bzr(['mkdir', 'subdir'])
73
self.assert_(os.path.isdir('subdir'))
71
self.run_bzr(['mkdir', 'subdir'], working_dir='dir')
72
self.assert_(os.path.isdir('dir/subdir'))
76
74
wt = WorkingTree.open('.')
148
146
new = b.repository.revision_tree(b.get_rev_id(2))
151
self.assertEqual(new.get_file_by_path('b/two').read(), 'old contents')
152
self.assertEqual(new.get_file_by_path('top').read(), 'old contents')
153
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')
157
157
# commit from here should do nothing
158
self.run_bzr(['commit', '.', '-m', 'commit subdir only', '--unchanged'])
158
self.run_bzr(['commit', '.', '-m', 'commit subdir only', '--unchanged'],
159
160
v3 = b.repository.revision_tree(b.get_rev_id(3))
161
self.assertEqual(v3.get_file_by_path('b/two').read(), 'old contents')
162
self.assertEqual(v3.get_file_by_path('top').read(), 'old contents')
163
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')
166
167
# commit in subdirectory commits whole tree
167
self.run_bzr(['commit', '-m', 'commit whole tree from subdir'])
168
self.run_bzr(['commit', '-m', 'commit whole tree from subdir'],
168
170
v4 = b.repository.revision_tree(b.get_rev_id(4))
170
self.assertEqual(v4.get_file_by_path('b/two').read(), 'new contents')
171
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')
174
176
# TODO: factor out some kind of assert_tree_state() method