13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
"""Tests of simple versioning operations"""
32
32
class TestVersioning(TestCaseInTempDir):
35
35
"""Basic 'bzr mkdir' operation"""
37
37
self.run_bzr('init')
38
self.run_bzr('mkdir', 'foo')
38
self.run_bzr('mkdir foo')
39
39
self.assert_(os.path.isdir('foo'))
41
self.run_bzr('mkdir', 'foo', retcode=3)
41
self.run_bzr('mkdir foo', retcode=3)
43
43
wt = WorkingTree.open('.')
45
45
delta = wt.changes_from(wt.basis_tree())
47
47
self.log('delta.added = %r' % delta.added)
54
54
"""'bzr mkdir' operation in subdirectory"""
56
56
self.run_bzr('init')
57
self.run_bzr('mkdir', 'dir')
57
self.run_bzr('mkdir dir')
58
58
self.assert_(os.path.isdir('dir'))
61
61
self.log('Run mkdir in subdir')
62
self.run_bzr('mkdir', 'subdir')
62
self.run_bzr('mkdir subdir')
63
63
self.assert_(os.path.isdir('subdir'))
66
66
wt = WorkingTree.open('.')
68
68
delta = wt.changes_from(wt.basis_tree())
70
70
self.log('delta.added = %r' % delta.added)
86
86
self.run_bzr('init')
89
self.run_bzr('mkdir', 'dir', 'a/dir', 'a/b/dir')
89
self.run_bzr('mkdir dir a/dir a/b/dir')
90
90
self.failUnless(os.path.isdir('dir'))
91
91
self.failUnless(os.path.isdir('a/dir'))
92
92
self.failUnless(os.path.isdir('a/b/dir'))
94
94
wt = WorkingTree.open('.')
95
95
wt_a = WorkingTree.open('a')
96
96
wt_b = WorkingTree.open('a/b')
98
98
delta = wt.changes_from(wt.basis_tree())
99
99
self.assertEquals(len(delta.added), 1)
100
100
self.assertEquals(delta.added[0][0], 'dir')
130
130
eq = self.assertEqual
132
132
self.build_tree(['a/', 'b/'])
135
135
b = Branch.open(u'.')
137
137
for fn in ('a/one', 'b/two', 'top'):
138
138
file(fn, 'w').write('old contents')
141
run_bzr('commit', '-m', 'first revision')
141
run_bzr(['commit', '-m', 'first revision'])
143
143
for fn in ('a/one', 'b/two', 'top'):
144
144
file(fn, 'w').write('new contents')
146
146
mutter('start selective subdir commit')
147
run_bzr('commit', 'a', '-m', 'commit a only')
147
run_bzr(['commit', 'a', '-m', 'commit a only'])
149
149
old = b.repository.revision_tree(b.get_rev_id(1))
150
150
new = b.repository.revision_tree(b.get_rev_id(2))
152
153
eq(new.get_file_by_path('b/two').read(), 'old contents')
153
154
eq(new.get_file_by_path('top').read(), 'old contents')
154
155
eq(new.get_file_by_path('a/one').read(), 'new contents')
157
159
# commit from here should do nothing
158
run_bzr('commit', '.', '-m', 'commit subdir only', '--unchanged')
160
run_bzr(['commit', '.', '-m', 'commit subdir only', '--unchanged'])
159
161
v3 = b.repository.revision_tree(b.get_rev_id(3))
160
163
eq(v3.get_file_by_path('b/two').read(), 'old contents')
161
164
eq(v3.get_file_by_path('top').read(), 'old contents')
162
165
eq(v3.get_file_by_path('a/one').read(), 'new contents')
164
168
# commit in subdirectory commits whole tree
165
run_bzr('commit', '-m', 'commit whole tree from subdir')
169
run_bzr(['commit', '-m', 'commit whole tree from subdir'])
166
170
v4 = b.repository.revision_tree(b.get_rev_id(4))
167
eq(v4.get_file_by_path('b/two').read(), 'new contents')
172
eq(v4.get_file_by_path('b/two').read(), 'new contents')
168
173
eq(v4.get_file_by_path('top').read(), 'new contents')
170
176
# TODO: factor out some kind of assert_tree_state() method
173
179
if __name__ == '__main__':