~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_testament.py

  • Committer: Robert Collins
  • Date: 2006-08-08 23:19:29 UTC
  • mfrom: (1884 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1912.
  • Revision ID: robertc@robertcollins.net-20060808231929-4e3e298190214b3a
current status

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
from bzrlib.tests import TestCaseWithTransport
26
26
from bzrlib.branch import Branch
27
 
from bzrlib.testament import Testament
 
27
from bzrlib.testament import Testament, StrictTestament
28
28
from bzrlib.trace import mutter
 
29
from bzrlib.transform import TreeTransform
29
30
from bzrlib.osutils import has_symlinks
30
31
 
31
32
 
46
47
                             ('src/foo.c', 'int main()\n{\n}\n')])
47
48
        self.wt.add(['hello', 'src', 'src/foo.c'],
48
49
                             ['hello-id', 'src-id', 'foo.c-id'])
 
50
        tt = TreeTransform(self.wt)
 
51
        trans_id = tt.trans_id_tree_path('hello')
 
52
        tt.set_executability(True, trans_id)
 
53
        tt.apply()
49
54
        self.wt.commit(message='add files and directories',
50
55
                 timestamp=1129025483,
51
56
                 timezone=36000,
70
75
        self.log('testament text form:\n' + text_form)
71
76
        self.assertEqual(text_form, REV_1_TESTAMENT)
72
77
 
 
78
    def test_strict_testment_text_form(self):
 
79
        """Conversion of testament to canonical text form."""
 
80
        t = StrictTestament.from_revision(self.b.repository, 'test@user-1')
 
81
        text_form = t.as_text()
 
82
        self.log('testament text form:\n' + text_form)
 
83
        self.assertEqualDiff(text_form, REV_1_STRICT_TESTAMENT)
 
84
 
73
85
    def test_testament_with_contents(self):
74
86
        """Testament containing a file and a directory."""
75
87
        t = Testament.from_revision(self.b.repository, 'test@user-2')
79
91
        actual_short = t.as_short_text()
80
92
        self.assertEqualDiff(actual_short, REV_2_SHORT)
81
93
 
 
94
    def test_strict_testament_with_contents(self):
 
95
        """Testament containing a file and a directory."""
 
96
        t = StrictTestament.from_revision(self.b.repository, 'test@user-2')
 
97
        text_form = t.as_text()
 
98
        self.log('testament text form:\n' + text_form)
 
99
        self.assertEqualDiff(text_form, REV_2_STRICT_TESTAMENT)
 
100
        actual_short = t.as_short_text()
 
101
        self.assertEqualDiff(actual_short, REV_2_SHORT_STRICT)
 
102
 
82
103
    def test_testament_command(self):
83
104
        """Testament containing a file and a directory."""
84
105
        out, err = self.run_bzr_captured(['testament', '--long'])
91
112
        self.assertEqualDiff(err, '')
92
113
        self.assertEqualDiff(out, REV_1_SHORT)
93
114
 
 
115
    def test_testament_command_3(self):
 
116
        """Command getting short testament of previous version."""
 
117
        out, err = self.run_bzr_captured(['testament', '-r1', '--strict'])
 
118
        self.assertEqualDiff(err, '')
 
119
        self.assertEqualDiff(out, REV_1_SHORT_STRICT)
 
120
 
94
121
    def test_testament_symlinks(self):
95
122
        """Testament containing symlink (where possible)"""
96
123
        if not has_symlinks():
153
180
    test branch
154
181
"""
155
182
 
 
183
REV_1_STRICT_TESTAMENT = """\
 
184
bazaar-ng testament version 2.1
 
185
revision-id: test@user-1
 
186
committer: test@user
 
187
timestamp: 1129025423
 
188
timezone: 0
 
189
parents:
 
190
message:
 
191
  initial null commit
 
192
inventory:
 
193
properties:
 
194
  branch-nick:
 
195
    test branch
 
196
"""
 
197
 
 
198
 
156
199
REV_1_SHORT = """\
157
200
bazaar-ng testament short form 1
158
201
revision-id: test@user-1
160
203
""" % sha(REV_1_TESTAMENT).hexdigest()
161
204
 
162
205
 
 
206
REV_1_SHORT_STRICT = """\
 
207
bazaar-ng testament short form 2.1
 
208
revision-id: test@user-1
 
209
sha1: %s
 
210
""" % sha(REV_1_STRICT_TESTAMENT).hexdigest()
 
211
 
 
212
 
163
213
REV_2_TESTAMENT = """\
164
214
bazaar-ng testament version 1
165
215
revision-id: test@user-2
180
230
"""
181
231
 
182
232
 
 
233
REV_2_STRICT_TESTAMENT = """\
 
234
bazaar-ng testament version 2.1
 
235
revision-id: test@user-2
 
236
committer: test@user
 
237
timestamp: 1129025483
 
238
timezone: 36000
 
239
parents:
 
240
  test@user-1
 
241
message:
 
242
  add files and directories
 
243
inventory:
 
244
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
 
245
  directory src src-id test@user-2 no
 
246
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
 
247
properties:
 
248
  branch-nick:
 
249
    test branch
 
250
"""
 
251
 
 
252
 
183
253
REV_2_SHORT = """\
184
254
bazaar-ng testament short form 1
185
255
revision-id: test@user-2
187
257
""" % sha(REV_2_TESTAMENT).hexdigest()
188
258
 
189
259
 
 
260
REV_2_SHORT_STRICT = """\
 
261
bazaar-ng testament short form 2.1
 
262
revision-id: test@user-2
 
263
sha1: %s
 
264
""" % sha(REV_2_STRICT_TESTAMENT).hexdigest()
 
265
 
 
266
 
190
267
REV_PROPS_TESTAMENT = """\
191
268
bazaar-ng testament version 1
192
269
revision-id: test@user-3