~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testtestament.py

  • Committer: Robert Collins
  • Date: 2005-10-17 11:56:54 UTC
  • mfrom: (1185.16.59)
  • Revision ID: robertc@robertcollins.net-20051017115654-662239e1587524a8
mergeĀ fromĀ martin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from sha import sha
23
23
import sys
24
24
 
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
30
31
 
31
 
 
32
32
class TestamentTests(TestCaseInTempDir):
33
 
 
34
33
    def setUp(self):
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'
41
39
                 timezone=0,
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'),
44
42
                             ('src/', ),
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,
50
48
                 timezone=36000,
51
49
                 rev_id='test@user-2',
95
93
        if not has_symlinks():
96
94
            return
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,
101
99
                 timezone=36000,
102
100
                 rev_id='test@user-3',
108
106
        """Testament to revision with extra properties"""
109
107
        props = dict(flavor='sour cherry\ncream cheese',
110
108
                     size='medium')
111
 
        self.b.working_tree().commit(message='revision with properties',
 
109
        self.b.commit(message='revision with properties',
112
110
                      timestamp=1129025493,
113
111
                      timezone=36000,
114
112
                      rev_id='test@user-3',
116
114
                      revprops=props)
117
115
        t = Testament.from_revision(self.b, 'test@user-3')
118
116
        self.assertEqualDiff(t.as_text(), REV_PROPS_TESTAMENT)
119
 
 
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)
127
117
                    
128
118
 
129
119
REV_1_TESTAMENT = """\
136
126
message:
137
127
  initial null commit
138
128
inventory:
139
 
properties:
140
 
  branch-nick:
141
 
    test branch
142
129
"""
143
130
 
144
131
REV_1_SHORT = """\
162
149
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
163
150
  directory src src-id
164
151
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
165
 
properties:
166
 
  branch-nick:
167
 
    test branch
168
152
"""
169
153
 
170
154
 
190
174
  directory src src-id
191
175
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
192
176
properties:
193
 
  branch-nick:
194
 
    test branch
195
177
  flavor:
196
178
    sour cherry
197
179
    cream cheese
215
197
  symlink link link-id wibble/linktarget
216
198
  directory src src-id
217
199
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
218
 
properties:
219
 
  branch-nick:
220
 
    test branch
221
200
"""