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