/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5452.4.3 by John Arbash Meinel
Merge bzr.dev to resolve bzr-2.3.txt (aka NEWS)
1
# Copyright (C) 2005-2010 Canonical Ltd
1185.16.12 by Martin Pool
- basic testament class
2
#
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.
7
#
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.
12
#
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
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1185.16.12 by Martin Pool
- basic testament class
16
17
"""Test testaments for gpg signing."""
18
1185.16.25 by Martin Pool
- testament symlink support
19
# TODO: Testaments with x-bits
1185.16.23 by Martin Pool
- clean up imports
20
1185.16.12 by Martin Pool
- basic testament class
21
import os
22
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
23
from breezy import osutils
24
from breezy.tests import TestCaseWithTransport
7206.4.1 by Jelmer Vernooij
Move breezy.testament to breezy.bzr.testament.
25
from breezy.bzr.testament import (
5798.1.1 by Jelmer Vernooij
Make Testament take a tree rather than a inventory.
26
    Testament,
27
    StrictTestament,
28
    StrictTestament3,
29
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
30
from breezy.tests.features import (
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
31
    SymlinkFeature,
32
    )
1185.16.12 by Martin Pool
- basic testament class
33
1442.1.62 by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions.
34
1930.2.1 by John Arbash Meinel
Move out the blackbox testament tests into a real blackbox module
35
class TestamentSetup(TestCaseWithTransport):
1442.1.62 by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions.
36
1185.16.15 by Martin Pool
- test text form for testaments
37
    def setUp(self):
1930.2.1 by John Arbash Meinel
Move out the blackbox testament tests into a real blackbox module
38
        super(TestamentSetup, self).setUp()
6437.14.2 by Jelmer Vernooij
Run subtree tests with development-subtree rather than deprecated dirstate-with-subtree.
39
        self.wt = self.make_branch_and_tree('.', format='development-subtree')
6855.3.1 by Jelmer Vernooij
Several more fixes.
40
        self.wt.set_root_id(b'TREE_ROT')
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
41
        b = self.b = self.wt.branch
1185.35.16 by Aaron Bentley
Fixed tests
42
        b.nick = "test branch"
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
43
        self.wt.commit(message='initial null commit',
7143.15.2 by Jelmer Vernooij
Run autopep8.
44
                       committer='test@user',
45
                       timestamp=1129025423,  # 'Tue Oct 11 20:10:23 2005'
46
                       timezone=0,
47
                       rev_id=b'test@user-1')
6855.4.1 by Jelmer Vernooij
Yet more bees.
48
        self.build_tree_contents([('hello', b'contents of hello file'),
7143.15.2 by Jelmer Vernooij
Run autopep8.
49
                                  ('src/', ),
50
                                  ('src/foo.c', b'int main()\n{\n}\n')])
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
51
        self.wt.add(['hello', 'src', 'src/foo.c'],
7143.15.2 by Jelmer Vernooij
Run autopep8.
52
                    [b'hello-id', b'src-id', b'foo.c-id'])
7350.3.1 by Jelmer Vernooij
Add Tree.get_transform.
53
        tt = self.wt.get_transform()
1551.7.5 by Aaron Bentley
Make sure strict testaments indicate when an execute bit is true
54
        trans_id = tt.trans_id_tree_path('hello')
55
        tt.set_executability(True, trans_id)
56
        tt.apply()
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
57
        self.wt.commit(message='add files and directories',
7143.15.2 by Jelmer Vernooij
Run autopep8.
58
                       timestamp=1129025483,
59
                       timezone=36000,
60
                       rev_id=b'test@user-2',
61
                       committer='test@user')
1185.16.15 by Martin Pool
- test text form for testaments
62
1930.2.1 by John Arbash Meinel
Move out the blackbox testament tests into a real blackbox module
63
64
class TestamentTests(TestamentSetup):
65
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
66
    def testament_class(self):
67
        return Testament
68
69
    def expected(self, key):
70
        return texts[self.testament_class()][key]
71
72
    def from_revision(self, repository, revision_id):
73
        return self.testament_class().from_revision(repository, revision_id)
74
1185.16.15 by Martin Pool
- test text form for testaments
75
    def test_null_testament(self):
76
        """Testament for a revision with no contents."""
6973.12.5 by Jelmer Vernooij
Add some u's for revision property names.
77
        t = self.from_revision(self.b.repository, b'test@user-1')
1185.16.12 by Martin Pool
- basic testament class
78
        ass = self.assertTrue
79
        eq = self.assertEqual
80
        ass(isinstance(t, Testament))
6973.12.5 by Jelmer Vernooij
Add some u's for revision property names.
81
        eq(t.revision_id, b'test@user-1')
1185.16.12 by Martin Pool
- basic testament class
82
        eq(t.committer, 'test@user')
83
        eq(t.timestamp, 1129025423)
84
        eq(t.timezone, 0)
85
1185.16.15 by Martin Pool
- test text form for testaments
86
    def test_testment_text_form(self):
87
        """Conversion of testament to canonical text form."""
6973.12.5 by Jelmer Vernooij
Add some u's for revision property names.
88
        t = self.from_revision(self.b.repository, b'test@user-1')
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
89
        text_form = t.as_text()
7045.2.4 by Jelmer Vernooij
Fix some more.
90
        self.log('testament text form:\n%s' % text_form)
91
        self.assertEqualDiff(text_form, self.expected('rev_1'))
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
92
        short_text_form = t.as_short_text()
7045.2.4 by Jelmer Vernooij
Fix some more.
93
        self.assertEqualDiff(short_text_form, self.expected('rev_1_short'))
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
94
1185.16.19 by Martin Pool
- testament now contains summary of parents and inventory
95
    def test_testament_with_contents(self):
96
        """Testament containing a file and a directory."""
6973.12.5 by Jelmer Vernooij
Add some u's for revision property names.
97
        t = self.from_revision(self.b.repository, b'test@user-2')
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
98
        text_form = t.as_text()
7045.2.11 by Jelmer Vernooij
Fix some testament tests.
99
        self.log('testament text form:\n%s' % text_form)
7045.2.4 by Jelmer Vernooij
Fix some more.
100
        self.assertEqualDiff(text_form, self.expected('rev_2'))
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
101
        actual_short = t.as_short_text()
7045.2.4 by Jelmer Vernooij
Fix some more.
102
        self.assertEqualDiff(actual_short, self.expected('rev_2_short'))
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
103
1185.16.25 by Martin Pool
- testament symlink support
104
    def test_testament_symlinks(self):
105
        """Testament containing symlink (where possible)"""
2949.5.1 by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate
106
        self.requireFeature(SymlinkFeature)
1185.16.25 by Martin Pool
- testament symlink support
107
        os.symlink('wibble/linktarget', 'link')
6855.4.1 by Jelmer Vernooij
Yet more bees.
108
        self.wt.add(['link'], [b'link-id'])
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
109
        self.wt.commit(message='add symlink',
7143.15.2 by Jelmer Vernooij
Run autopep8.
110
                       timestamp=1129025493,
111
                       timezone=36000,
112
                       rev_id=b'test@user-3',
113
                       committer='test@user')
6973.12.5 by Jelmer Vernooij
Add some u's for revision property names.
114
        t = self.from_revision(self.b.repository, b'test@user-3')
7045.2.4 by Jelmer Vernooij
Fix some more.
115
        self.assertEqualDiff(t.as_text(), self.expected('rev_3'))
1185.16.25 by Martin Pool
- testament symlink support
116
1185.16.59 by mbp at sourcefrog
- store revprops in testaments
117
    def test_testament_revprops(self):
118
        """Testament to revision with extra properties"""
6973.12.9 by Jelmer Vernooij
More fixes.
119
        props = {u'flavor': 'sour cherry\ncream cheese',
120
                 u'size': 'medium',
121
                 u'empty': '',
122
                 }
1534.4.36 by Robert Collins
Finish deprecating Branch.working_tree()
123
        self.wt.commit(message='revision with properties',
7143.15.2 by Jelmer Vernooij
Run autopep8.
124
                       timestamp=1129025493,
125
                       timezone=36000,
126
                       rev_id=b'test@user-3',
127
                       committer='test@user',
128
                       revprops=props)
6973.12.5 by Jelmer Vernooij
Add some u's for revision property names.
129
        t = self.from_revision(self.b.repository, b'test@user-3')
7045.2.4 by Jelmer Vernooij
Fix some more.
130
        self.assertEqualDiff(t.as_text(), self.expected('rev_props'))
1442.1.62 by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions.
131
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
132
    def test_testament_unicode_commit_message(self):
1558.1.3 by Aaron Bentley
Fixed deprecated op use in test suite
133
        self.wt.commit(
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
134
            message=u'non-ascii commit \N{COPYRIGHT SIGN} me',
135
            timestamp=1129025493,
136
            timezone=36000,
6855.4.1 by Jelmer Vernooij
Yet more bees.
137
            rev_id=b'test@user-3',
5485.4.1 by Martin
Fix tests passing non-ascii committer str and add guard in commit
138
            committer=u'Erik B\xe5gfors <test@user>',
7143.15.2 by Jelmer Vernooij
Run autopep8.
139
            revprops={u'uni': u'\xb5'}
1930.2.2 by John Arbash Meinel
Avoid needless encode/decode. Only encode at the boundary (as suggested by hpk)
140
            )
6973.12.5 by Jelmer Vernooij
Add some u's for revision property names.
141
        t = self.from_revision(self.b.repository, b'test@user-3')
1553.3.4 by Marien Zwart
Move the encoding step into the test to make it more obvious we are comparing bytestrings.
142
        self.assertEqualDiff(
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
143
            self.expected('sample_unicode').encode('utf-8'), t.as_text())
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
144
5798.1.1 by Jelmer Vernooij
Make Testament take a tree rather than a inventory.
145
    def test_from_tree(self):
6973.5.2 by Jelmer Vernooij
Add more bees.
146
        tree = self.b.repository.revision_tree(b'test@user-2')
5798.1.1 by Jelmer Vernooij
Make Testament take a tree rather than a inventory.
147
        testament = self.testament_class().from_revision_tree(tree)
148
        text_1 = testament.as_short_text()
149
        text_2 = self.from_revision(self.b.repository,
6973.12.5 by Jelmer Vernooij
Add some u's for revision property names.
150
                                    b'test@user-2').as_short_text()
5798.1.1 by Jelmer Vernooij
Make Testament take a tree rather than a inventory.
151
        self.assertEqual(text_1, text_2)
152
1442.1.62 by Robert Collins
Allow creation of testaments from uncommitted data, and use that to get signatures before committing revisions.
153
    def test___init__(self):
6973.5.2 by Jelmer Vernooij
Add more bees.
154
        revision = self.b.repository.get_revision(b'test@user-2')
155
        tree = self.b.repository.revision_tree(b'test@user-2')
5798.1.1 by Jelmer Vernooij
Make Testament take a tree rather than a inventory.
156
        testament_1 = self.testament_class()(revision, tree)
1910.2.62 by Aaron Bentley
Cleanups
157
        text_1 = testament_1.as_short_text()
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
158
        text_2 = self.from_revision(self.b.repository,
6973.12.5 by Jelmer Vernooij
Add some u's for revision property names.
159
                                    b'test@user-2').as_short_text()
1910.2.62 by Aaron Bentley
Cleanups
160
        self.assertEqual(text_1, text_2)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
161
1185.16.25 by Martin Pool
- testament symlink support
162
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
163
class TestamentTestsStrict(TestamentTests):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
164
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
165
    def testament_class(self):
166
        return StrictTestament
167
168
169
class TestamentTestsStrict2(TestamentTests):
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
170
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
171
    def testament_class(self):
1910.2.64 by Aaron Bentley
Changes from review
172
        return StrictTestament3
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
173
174
6791.2.3 by Jelmer Vernooij
Fix more imports.
175
REV_1_TESTAMENT = b"""\
1185.16.25 by Martin Pool
- testament symlink support
176
bazaar-ng testament version 1
177
revision-id: test@user-1
178
committer: test@user
179
timestamp: 1129025423
180
timezone: 0
181
parents:
182
message:
183
  initial null commit
184
inventory:
1185.35.16 by Aaron Bentley
Fixed tests
185
properties:
186
  branch-nick:
187
    test branch
1185.16.25 by Martin Pool
- testament symlink support
188
"""
189
1910.2.62 by Aaron Bentley
Cleanups
190
6791.2.3 by Jelmer Vernooij
Fix more imports.
191
REV_1_STRICT_TESTAMENT = b"""\
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
192
bazaar-ng testament version 2.1
193
revision-id: test@user-1
194
committer: test@user
195
timestamp: 1129025423
196
timezone: 0
197
parents:
198
message:
199
  initial null commit
200
inventory:
201
properties:
202
  branch-nick:
203
    test branch
204
"""
205
1910.2.62 by Aaron Bentley
Cleanups
206
6791.2.3 by Jelmer Vernooij
Fix more imports.
207
REV_1_STRICT_TESTAMENT3 = b"""\
1910.2.64 by Aaron Bentley
Changes from review
208
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
209
revision-id: test@user-1
210
committer: test@user
211
timestamp: 1129025423
212
timezone: 0
213
parents:
214
message:
215
  initial null commit
216
inventory:
1731.1.53 by Aaron Bentley
Fix testament text now that root are variable
217
  directory . TREE_ROT test@user-1 no
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
218
properties:
219
  branch-nick:
220
    test branch
221
"""
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
222
1910.2.62 by Aaron Bentley
Cleanups
223
7027.3.3 by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents.
224
REV_1_SHORT = b"""\
1185.16.25 by Martin Pool
- testament symlink support
225
bazaar-ng testament short form 1
226
revision-id: test@user-1
227
sha1: %s
5849.1.1 by Jelmer Vernooij
Use osutils.sha_string() when possible.
228
""" % osutils.sha_string(REV_1_TESTAMENT)
1185.16.25 by Martin Pool
- testament symlink support
229
1185.16.24 by Martin Pool
- add and test 'testament' builtin command
230
7027.3.3 by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents.
231
REV_1_SHORT_STRICT = b"""\
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
232
bazaar-ng testament short form 2.1
233
revision-id: test@user-1
234
sha1: %s
5849.1.1 by Jelmer Vernooij
Use osutils.sha_string() when possible.
235
""" % osutils.sha_string(REV_1_STRICT_TESTAMENT)
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
236
237
7027.3.3 by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents.
238
REV_1_SHORT_STRICT3 = b"""\
1910.2.64 by Aaron Bentley
Changes from review
239
bazaar testament short form 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
240
revision-id: test@user-1
241
sha1: %s
5849.1.1 by Jelmer Vernooij
Use osutils.sha_string() when possible.
242
""" % osutils.sha_string(REV_1_STRICT_TESTAMENT3)
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
243
244
6791.2.3 by Jelmer Vernooij
Fix more imports.
245
REV_2_TESTAMENT = b"""\
1185.16.19 by Martin Pool
- testament now contains summary of parents and inventory
246
bazaar-ng testament version 1
247
revision-id: test@user-2
248
committer: test@user
1185.16.22 by Martin Pool
- more testament development
249
timestamp: 1129025483
1185.16.19 by Martin Pool
- testament now contains summary of parents and inventory
250
timezone: 36000
251
parents:
252
  test@user-1
253
message:
254
  add files and directories
255
inventory:
1185.16.22 by Martin Pool
- more testament development
256
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
257
  directory src src-id
258
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
1185.35.16 by Aaron Bentley
Fixed tests
259
properties:
260
  branch-nick:
261
    test branch
1185.16.19 by Martin Pool
- testament now contains summary of parents and inventory
262
"""
1185.16.25 by Martin Pool
- testament symlink support
263
264
6791.2.3 by Jelmer Vernooij
Fix more imports.
265
REV_2_STRICT_TESTAMENT = b"""\
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
266
bazaar-ng testament version 2.1
267
revision-id: test@user-2
268
committer: test@user
269
timestamp: 1129025483
270
timezone: 36000
271
parents:
272
  test@user-1
273
message:
274
  add files and directories
275
inventory:
1551.7.5 by Aaron Bentley
Make sure strict testaments indicate when an execute bit is true
276
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
277
  directory src src-id test@user-2 no
278
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
279
properties:
280
  branch-nick:
281
    test branch
282
"""
283
284
6791.2.3 by Jelmer Vernooij
Fix more imports.
285
REV_2_STRICT_TESTAMENT3 = b"""\
1910.2.64 by Aaron Bentley
Changes from review
286
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
287
revision-id: test@user-2
288
committer: test@user
289
timestamp: 1129025483
290
timezone: 36000
291
parents:
292
  test@user-1
293
message:
294
  add files and directories
295
inventory:
2230.3.19 by Aaron Bentley
Fix testament tests
296
  directory . TREE_ROT test@user-1 no
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
297
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
298
  directory src src-id test@user-2 no
299
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
300
properties:
301
  branch-nick:
302
    test branch
303
"""
304
1910.2.62 by Aaron Bentley
Cleanups
305
7027.3.3 by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents.
306
REV_2_SHORT = b"""\
1185.16.25 by Martin Pool
- testament symlink support
307
bazaar-ng testament short form 1
308
revision-id: test@user-2
309
sha1: %s
5849.1.1 by Jelmer Vernooij
Use osutils.sha_string() when possible.
310
""" % osutils.sha_string(REV_2_TESTAMENT)
1185.16.25 by Martin Pool
- testament symlink support
311
312
7027.3.3 by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents.
313
REV_2_SHORT_STRICT = b"""\
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
314
bazaar-ng testament short form 2.1
315
revision-id: test@user-2
316
sha1: %s
5849.1.1 by Jelmer Vernooij
Use osutils.sha_string() when possible.
317
""" % osutils.sha_string(REV_2_STRICT_TESTAMENT)
1551.7.1 by Aaron Bentley
Implement --strict at commandline, fix up strict format
318
319
7027.3.3 by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents.
320
REV_2_SHORT_STRICT3 = b"""\
1910.2.64 by Aaron Bentley
Changes from review
321
bazaar testament short form 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
322
revision-id: test@user-2
323
sha1: %s
5849.1.1 by Jelmer Vernooij
Use osutils.sha_string() when possible.
324
""" % osutils.sha_string(REV_2_STRICT_TESTAMENT3)
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
325
326
6791.2.3 by Jelmer Vernooij
Fix more imports.
327
REV_PROPS_TESTAMENT = b"""\
1185.16.59 by mbp at sourcefrog
- store revprops in testaments
328
bazaar-ng testament version 1
329
revision-id: test@user-3
330
committer: test@user
331
timestamp: 1129025493
332
timezone: 36000
333
parents:
334
  test@user-2
335
message:
336
  revision with properties
337
inventory:
338
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
339
  directory src src-id
340
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
341
properties:
1185.35.16 by Aaron Bentley
Fixed tests
342
  branch-nick:
343
    test branch
1886.1.5 by John Arbash Meinel
Assert that Testament can handle empty revprops as well
344
  empty:
1185.16.59 by mbp at sourcefrog
- store revprops in testaments
345
  flavor:
346
    sour cherry
347
    cream cheese
348
  size:
349
    medium
350
"""
351
352
6791.2.3 by Jelmer Vernooij
Fix more imports.
353
REV_PROPS_TESTAMENT_STRICT = b"""\
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
354
bazaar-ng testament version 2.1
355
revision-id: test@user-3
356
committer: test@user
357
timestamp: 1129025493
358
timezone: 36000
359
parents:
360
  test@user-2
361
message:
362
  revision with properties
363
inventory:
364
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
365
  directory src src-id test@user-2 no
366
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
367
properties:
368
  branch-nick:
369
    test branch
370
  empty:
371
  flavor:
372
    sour cherry
373
    cream cheese
374
  size:
375
    medium
376
"""
377
378
6791.2.3 by Jelmer Vernooij
Fix more imports.
379
REV_PROPS_TESTAMENT_STRICT3 = b"""\
1910.2.64 by Aaron Bentley
Changes from review
380
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
381
revision-id: test@user-3
382
committer: test@user
383
timestamp: 1129025493
384
timezone: 36000
385
parents:
386
  test@user-2
387
message:
388
  revision with properties
389
inventory:
2230.3.19 by Aaron Bentley
Fix testament tests
390
  directory . TREE_ROT test@user-1 no
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
391
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
392
  directory src src-id test@user-2 no
393
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
394
properties:
395
  branch-nick:
396
    test branch
397
  empty:
398
  flavor:
399
    sour cherry
400
    cream cheese
401
  size:
402
    medium
403
"""
404
405
6791.2.3 by Jelmer Vernooij
Fix more imports.
406
REV_3_TESTAMENT = b"""\
1185.16.25 by Martin Pool
- testament symlink support
407
bazaar-ng testament version 1
408
revision-id: test@user-3
409
committer: test@user
410
timestamp: 1129025493
411
timezone: 36000
412
parents:
413
  test@user-2
414
message:
415
  add symlink
416
inventory:
417
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
418
  symlink link link-id wibble/linktarget
419
  directory src src-id
420
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
1185.35.16 by Aaron Bentley
Fixed tests
421
properties:
422
  branch-nick:
423
    test branch
1185.16.25 by Martin Pool
- testament symlink support
424
"""
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
425
1553.3.3 by Marien Zwart
Whitespace cleanup (pep 3)
426
6791.2.3 by Jelmer Vernooij
Fix more imports.
427
REV_3_TESTAMENT_STRICT = b"""\
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
428
bazaar-ng testament version 2.1
429
revision-id: test@user-3
430
committer: test@user
431
timestamp: 1129025493
432
timezone: 36000
433
parents:
434
  test@user-2
435
message:
436
  add symlink
437
inventory:
438
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
439
  symlink link link-id wibble/linktarget test@user-3 no
440
  directory src src-id test@user-2 no
441
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
442
properties:
443
  branch-nick:
444
    test branch
445
"""
446
447
6791.2.3 by Jelmer Vernooij
Fix more imports.
448
REV_3_TESTAMENT_STRICT3 = b"""\
1910.2.64 by Aaron Bentley
Changes from review
449
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
450
revision-id: test@user-3
451
committer: test@user
452
timestamp: 1129025493
453
timezone: 36000
454
parents:
455
  test@user-2
456
message:
457
  add symlink
458
inventory:
2230.3.19 by Aaron Bentley
Fix testament tests
459
  directory . TREE_ROT test@user-1 no
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
460
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
461
  symlink link link-id wibble/linktarget test@user-3 no
462
  directory src src-id test@user-2 no
463
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
464
properties:
465
  branch-nick:
466
    test branch
467
"""
468
1910.2.62 by Aaron Bentley
Cleanups
469
1553.3.4 by Marien Zwart
Move the encoding step into the test to make it more obvious we are comparing bytestrings.
470
SAMPLE_UNICODE_TESTAMENT = u"""\
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
471
bazaar-ng testament version 1
472
revision-id: test@user-3
1930.2.2 by John Arbash Meinel
Avoid needless encode/decode. Only encode at the boundary (as suggested by hpk)
473
committer: Erik B\xe5gfors <test@user>
1553.3.1 by Marien Zwart
Make Testament.as_text_lines return utf-8 instead of unicode objects and add a test for this.
474
timestamp: 1129025493
475
timezone: 36000
476
parents:
477
  test@user-2
478
message:
479
  non-ascii commit \N{COPYRIGHT SIGN} me
480
inventory:
481
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
482
  directory src src-id
483
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
484
properties:
485
  branch-nick:
486
    test branch
1930.2.2 by John Arbash Meinel
Avoid needless encode/decode. Only encode at the boundary (as suggested by hpk)
487
  uni:
488
    \xb5
1553.3.4 by Marien Zwart
Move the encoding step into the test to make it more obvious we are comparing bytestrings.
489
"""
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
490
491
492
SAMPLE_UNICODE_TESTAMENT_STRICT = u"""\
493
bazaar-ng testament version 2.1
494
revision-id: test@user-3
495
committer: Erik B\xe5gfors <test@user>
496
timestamp: 1129025493
497
timezone: 36000
498
parents:
499
  test@user-2
500
message:
501
  non-ascii commit \N{COPYRIGHT SIGN} me
502
inventory:
503
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
504
  directory src src-id test@user-2 no
505
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
506
properties:
507
  branch-nick:
508
    test branch
509
  uni:
510
    \xb5
511
"""
512
513
1910.2.64 by Aaron Bentley
Changes from review
514
SAMPLE_UNICODE_TESTAMENT_STRICT3 = u"""\
515
bazaar testament version 3 strict
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
516
revision-id: test@user-3
517
committer: Erik B\xe5gfors <test@user>
518
timestamp: 1129025493
519
timezone: 36000
520
parents:
521
  test@user-2
522
message:
523
  non-ascii commit \N{COPYRIGHT SIGN} me
524
inventory:
2230.3.19 by Aaron Bentley
Fix testament tests
525
  directory . TREE_ROT test@user-1 no
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
526
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
527
  directory src src-id test@user-2 no
528
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
529
properties:
530
  branch-nick:
531
    test branch
532
  uni:
533
    \xb5
534
"""
535
536
537
texts = {
7143.15.2 by Jelmer Vernooij
Run autopep8.
538
    Testament: {'rev_1': REV_1_TESTAMENT,
539
                'rev_1_short': REV_1_SHORT,
540
                'rev_2': REV_2_TESTAMENT,
541
                'rev_2_short': REV_2_SHORT,
542
                'rev_3': REV_3_TESTAMENT,
543
                'rev_props': REV_PROPS_TESTAMENT,
544
                'sample_unicode': SAMPLE_UNICODE_TESTAMENT,
545
                },
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
546
    StrictTestament: {'rev_1': REV_1_STRICT_TESTAMENT,
547
                      'rev_1_short': REV_1_SHORT_STRICT,
548
                      'rev_2': REV_2_STRICT_TESTAMENT,
549
                      'rev_2_short': REV_2_SHORT_STRICT,
550
                      'rev_3': REV_3_TESTAMENT_STRICT,
551
                      'rev_props': REV_PROPS_TESTAMENT_STRICT,
552
                      'sample_unicode': SAMPLE_UNICODE_TESTAMENT_STRICT,
7143.15.2 by Jelmer Vernooij
Run autopep8.
553
                      },
1910.2.64 by Aaron Bentley
Changes from review
554
    StrictTestament3: {'rev_1': REV_1_STRICT_TESTAMENT3,
7143.15.2 by Jelmer Vernooij
Run autopep8.
555
                       'rev_1_short': REV_1_SHORT_STRICT3,
556
                       'rev_2': REV_2_STRICT_TESTAMENT3,
557
                       'rev_2_short': REV_2_SHORT_STRICT3,
558
                       'rev_3': REV_3_TESTAMENT_STRICT3,
559
                       'rev_props': REV_PROPS_TESTAMENT_STRICT3,
560
                       'sample_unicode': SAMPLE_UNICODE_TESTAMENT_STRICT3,
561
                       },
1910.2.54 by Aaron Bentley
Implement testament format 3 strict
562
}