1
# Copyright (C) 2005 by Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
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
18
"""Tests of simple versioning operations"""
21
from bzrlib.selftest import InTempDir
23
class Mkdir(InTempDir):
25
"""Basic 'bzr mkdir' operation"""
26
from bzrlib.commands import run_bzr
30
run_bzr(['mkdir', 'foo'])
31
self.assert_(os.path.isdir('foo'))
33
self.assertRaises(OSError, run_bzr, ['mkdir', 'foo'])
35
from bzrlib.diff import compare_trees, TreeDelta
36
from bzrlib.branch import Branch
39
delta = compare_trees(b.basis_tree(), b.working_tree())
41
self.assertEquals(len(delta.added), 1)
42
self.assertEquals(delta.added[0][0], 'foo')
43
self.failIf(delta.modified)
47
class AddInUnversioned(InTempDir):
49
"""Try to add a file in an unversioned directory.
51
smart_add may eventually add the parent as necessary, but simple
52
branch add doesn't do that.
54
from bzrlib.branch import Branch
56
from bzrlib.errors import NotVersionedError
58
b = Branch('.', init=True)
60
self.build_tree(['foo/',
63
self.assertRaises(NotVersionedError,
68
class SubdirCommit(InTempDir):
70
"""Various commits from a subdirectory"""
72
from bzrlib.branch import Branch
73
from bzrlib.commands import run_bzr
76
b = Branch('.', init=True)
77
self.build_tree(['src/', 'src/foo.c', 'README'])
79
self.assertEqual(sorted(b.unknowns()),
82
self.assertEqual(run_bzr(['version']), 0)
84
self.assertEqual(run_bzr(['add']), 0)