25
from bzrlib.selftest import InTempDir, BzrTestBase
26
from bzrlib.selftest import BzrTestBase, TestCaseInTempDir
26
27
from bzrlib.branch import Branch
29
class Mkdir(InTempDir):
30
logger = logging.getLogger('bzr.test.versioning')
34
class TestVersioning(TestCaseInTempDir):
31
37
"""Basic 'bzr mkdir' operation"""
32
38
from bzrlib.commands import run_bzr
49
55
self.assertEquals(delta.added[0][0], 'foo')
50
56
self.failIf(delta.modified)
54
class AddInUnversioned(InTempDir):
58
def test_add_in_unversioned(self):
56
59
"""Try to add a file in an unversioned directory.
58
61
smart_add may eventually add the parent as necessary, but simple
74
class SubdirCommit(BzrTestBase):
76
self.check_and_upgrade()
79
def test_subdir_add(self):
80
"""Add in subdirectory should add only things from there down"""
82
from bzrlib.branch import Branch
83
from bzrlib.commands import run_bzr
89
b = Branch('.', init=True)
90
self.build_tree(['src/', 'README'])
92
eq(sorted(b.unknowns()),
95
eq(run_bzr(['add', 'src']), 0)
97
self.build_tree(['src/foo.c'])
100
eq(run_bzr(['add']), 0)
102
eq(sorted(b.unknowns()),
104
eq(len(b.inventory), 3)
107
eq(run_bzr(['add']), 0)
108
eq(list(b.unknowns()), [])
110
self.check_and_upgrade()
113
def check_and_upgrade(self):
114
"""After all the above changes, run the check and upgrade commands.
116
The upgrade should be a no-op."""
118
debug('branch has %d revisions', b.revno())
120
debug('check branch...')
121
from bzrlib.check import check
124
debug('upgrade branch...')
125
from bzrlib.upgrade import upgrade
128
debug('check branch...')
129
from bzrlib.check import check
135
class SubdirCommit(TestCaseInTempDir):
137
def test_subdir_commit(self):
76
138
"""Test committing a subdirectory, and committing within a directory."""
77
139
run_bzr = self.run_bzr
78
140
eq = self.assertEqual
117
179
# TODO: factor out some kind of assert_tree_state() method
121
class SubdirAdd(InTempDir):
123
"""Add in subdirectory should add only things from there down"""
125
from bzrlib.branch import Branch
126
from bzrlib.commands import run_bzr
128
eq = self.assertEqual
132
b = Branch('.', init=True)
133
self.build_tree(['src/', 'README'])
135
eq(sorted(b.unknowns()),
138
eq(run_bzr(['add', 'src']), 0)
140
self.build_tree(['src/foo.c'])
143
eq(run_bzr(['add']), 0)
145
eq(sorted(b.unknowns()),
147
eq(len(b.inventory), 3)
150
eq(run_bzr(['add']), 0)
151
eq(list(b.unknowns()), [])