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
20
from bzrlib.selftest import TestCaseInTempDir
21
from bzrlib.branch import Branch
22
from bzrlib.commit import Commit
25
class TestCommit(TestCaseInTempDir):
26
def test_simple_commit(self):
27
"""Commit and check two versions of a single file."""
28
b = Branch('.', init=True)
29
file('hello', 'w').write('hello world')
31
b.commit(message='add hello')
32
file_id = b.working_tree().path2id('hello')
34
file('hello', 'w').write('version 2')
35
b.commit(message='commit 2')
37
eq = self.assertEquals
39
rh = b.revision_history()
40
rev = b.get_revision(rh[0])
41
eq(rev.message, 'add hello')
43
tree1 = b.revision_tree(rh[0])
44
text = tree1.get_file_text(file_id)
45
eq(text, 'hello world')
47
tree2 = b.revision_tree(rh[1])
48
eq(tree2.get_file_text(file_id), 'version 2')
51
def test_delete_commit(self):
52
"""Test a commit with a deleted file"""
54
def test_removed_commit(self):
55
"""Test a commit with a removed file"""
58
if __name__ == '__main__':