18
18
"""Tests of simple versioning operations"""
21
from bzrlib.selftest import InTempDir
20
# TODO: test adding a file whose directory is not versioned
21
# TODO: test trying to commit within a directory that is not yet added
25
from bzrlib.selftest import InTempDir, BzrTestBase
26
from bzrlib.branch import Branch
23
29
class Mkdir(InTempDir):
25
31
"""Basic 'bzr mkdir' operation"""
26
32
from bzrlib.commands import run_bzr
30
35
run_bzr(['mkdir', 'foo'])
68
class SubdirCommit(InTempDir):
72
class SubdirCommit(BzrTestBase):
74
"""Test committing a subdirectory, and committing within a directory."""
75
run_bzr = self.run_bzr
78
self.build_tree(['a/', 'b/'])
83
for fn in ('a/one', 'b/two', 'top'):
84
file(fn, 'w').write('old contents')
87
run_bzr('commit', '-m', 'first revision')
89
for fn in ('a/one', 'b/two', 'top'):
90
file(fn, 'w').write('new contents')
92
run_bzr('commit', 'a', '-m', 'commit a only')
94
old = b.revision_tree(b.lookup_revision(1))
95
new = b.revision_tree(b.lookup_revision(2))
97
eq(new.get_file_by_path('b/two').read(), 'old contents')
98
eq(new.get_file_by_path('top').read(), 'old contents')
99
eq(new.get_file_by_path('a/one').read(), 'new contents')
102
# commit from here should do nothing
103
run_bzr('commit', '.', '-m', 'commit subdir again', '--unchanged')
104
v3 = b.revision_tree(b.lookup_revision(3))
105
eq(v3.get_file_by_path('b/two').read(), 'old contents')
106
eq(v3.get_file_by_path('top').read(), 'old contents')
107
eq(v3.get_file_by_path('a/one').read(), 'new contents')
109
# commit in subdirectory commits whole tree
110
run_bzr('commit', '-m', 'commit in subdir')
111
v4 = b.revision_tree(b.lookup_revision(4))
112
eq(v4.get_file_by_path('b/two').read(), 'new contents')
113
eq(v4.get_file_by_path('top').read(), 'new contents')
115
# TODO: factor out some kind of assert_tree_state() method
73
119
class SubdirAdd(InTempDir):