22
22
from sha import sha
25
from bzrlib.tests import TestCaseInTempDir
25
from bzrlib.selftest import TestCaseInTempDir
26
from bzrlib.selftest.treeshape import build_tree_contents
26
27
from bzrlib.branch import Branch
27
28
from bzrlib.testament import Testament
28
29
from bzrlib.trace import mutter
29
30
from bzrlib.osutils import has_symlinks
32
32
class TestamentTests(TestCaseInTempDir):
35
34
super(TestamentTests, self).setUp()
36
b = self.b = Branch.initialize(u'.')
37
b.nick = "test branch"
38
b.working_tree().commit(message='initial null commit',
35
b = self.b = Branch.initialize('.')
36
b.commit(message='initial null commit',
39
37
committer='test@user',
40
38
timestamp=1129025423, # 'Tue Oct 11 20:10:23 2005'
42
40
rev_id='test@user-1')
43
self.build_tree_contents([('hello', 'contents of hello file'),
41
build_tree_contents([('hello', 'contents of hello file'),
45
43
('src/foo.c', 'int main()\n{\n}\n')])
46
b.working_tree().add(['hello', 'src', 'src/foo.c'],
47
['hello-id', 'src-id', 'foo.c-id'])
48
b.working_tree().commit(message='add files and directories',
44
b.add(['hello', 'src', 'src/foo.c'],
45
['hello-id', 'src-id', 'foo.c-id'])
46
b.commit(message='add files and directories',
49
47
timestamp=1129025483,
51
49
rev_id='test@user-2',
95
93
if not has_symlinks():
97
95
os.symlink('wibble/linktarget', 'link')
98
self.b.working_tree().add(['link'], ['link-id'])
99
self.b.working_tree().commit(message='add symlink',
96
self.b.add(['link'], ['link-id'])
97
self.b.commit(message='add symlink',
100
98
timestamp=1129025493,
102
100
rev_id='test@user-3',
108
106
"""Testament to revision with extra properties"""
109
107
props = dict(flavor='sour cherry\ncream cheese',
111
self.b.working_tree().commit(message='revision with properties',
109
self.b.commit(message='revision with properties',
112
110
timestamp=1129025493,
114
112
rev_id='test@user-3',
117
115
t = Testament.from_revision(self.b, 'test@user-3')
118
116
self.assertEqualDiff(t.as_text(), REV_PROPS_TESTAMENT)
120
def test___init__(self):
121
revision = self.b.get_revision('test@user-2')
122
inventory = self.b.get_inventory('test@user-2')
123
testament_1 = Testament(revision, inventory).as_short_text()
124
testament_2 = Testament.from_revision(self.b,
125
'test@user-2').as_short_text()
126
self.assertEqual(testament_1, testament_2)
129
119
REV_1_TESTAMENT = """\