1
# Copyright (C) 2005, 2006 Canonical Ltd
1
# Copyright (C) 2005-2006 by Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
"""Test testaments for gpg signing."""
19
19
# TODO: Testaments with x-bits
23
from bzrlib import osutils
24
from bzrlib.tests import SymlinkFeature, TestCaseWithTransport
24
from bzrlib.tests import TestCaseWithTransport
25
25
from bzrlib.testament import Testament, StrictTestament, StrictTestament3
26
26
from bzrlib.transform import TreeTransform
27
from bzrlib.osutils import has_symlinks
29
30
class TestamentSetup(TestCaseWithTransport):
32
33
super(TestamentSetup, self).setUp()
33
self.wt = self.make_branch_and_tree('.', format='dirstate-with-subtree')
34
self.wt.set_root_id('TREE_ROT')
34
self.wt = self.make_branch_and_tree('.')
35
35
b = self.b = self.wt.branch
36
36
b.nick = "test branch"
37
37
self.wt.commit(message='initial null commit',
98
98
def test_testament_symlinks(self):
99
99
"""Testament containing symlink (where possible)"""
100
self.requireFeature(SymlinkFeature)
100
if not has_symlinks():
101
102
os.symlink('wibble/linktarget', 'link')
102
103
self.wt.add(['link'], ['link-id'])
103
104
self.wt.commit(message='add symlink',
141
142
inventory = self.b.repository.get_inventory('test@user-2')
142
143
testament_1 = self.testament_class()(revision, inventory)
143
144
text_1 = testament_1.as_short_text()
144
text_2 = self.from_revision(self.b.repository,
145
text_2 = self.from_revision(self.b.repository,
145
146
'test@user-2').as_short_text()
146
147
self.assertEqual(text_1, text_2)
149
150
class TestamentTestsStrict(TestamentTests):
151
152
def testament_class(self):
152
153
return StrictTestament
155
156
class TestamentTestsStrict2(TestamentTests):
157
158
def testament_class(self):
158
159
return StrictTestament3
211
212
bazaar-ng testament short form 1
212
213
revision-id: test@user-1
214
""" % osutils.sha(REV_1_TESTAMENT).hexdigest()
215
""" % sha(REV_1_TESTAMENT).hexdigest()
217
218
REV_1_SHORT_STRICT = """\
218
219
bazaar-ng testament short form 2.1
219
220
revision-id: test@user-1
221
""" % osutils.sha(REV_1_STRICT_TESTAMENT).hexdigest()
222
""" % sha(REV_1_STRICT_TESTAMENT).hexdigest()
224
225
REV_1_SHORT_STRICT3 = """\
225
226
bazaar testament short form 3 strict
226
227
revision-id: test@user-1
228
""" % osutils.sha(REV_1_STRICT_TESTAMENT3).hexdigest()
229
""" % sha(REV_1_STRICT_TESTAMENT3).hexdigest()
231
232
REV_2_TESTAMENT = """\
280
281
add files and directories
282
directory . TREE_ROT test@user-1 no
283
directory . TREE_ROOT test@user-2 no
283
284
file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
284
285
directory src src-id test@user-2 no
285
286
file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
293
294
bazaar-ng testament short form 1
294
295
revision-id: test@user-2
296
""" % osutils.sha(REV_2_TESTAMENT).hexdigest()
297
""" % sha(REV_2_TESTAMENT).hexdigest()
299
300
REV_2_SHORT_STRICT = """\
300
301
bazaar-ng testament short form 2.1
301
302
revision-id: test@user-2
303
""" % osutils.sha(REV_2_STRICT_TESTAMENT).hexdigest()
304
""" % sha(REV_2_STRICT_TESTAMENT).hexdigest()
306
307
REV_2_SHORT_STRICT3 = """\
307
308
bazaar testament short form 3 strict
308
309
revision-id: test@user-2
310
""" % osutils.sha(REV_2_STRICT_TESTAMENT3).hexdigest()
311
""" % sha(REV_2_STRICT_TESTAMENT3).hexdigest()
313
314
REV_PROPS_TESTAMENT = """\
374
375
revision with properties
376
directory . TREE_ROT test@user-1 no
377
directory . TREE_ROOT test@user-3 no
377
378
file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
378
379
directory src src-id test@user-2 no
379
380
file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
445
directory . TREE_ROT test@user-1 no
446
directory . TREE_ROOT test@user-3 no
446
447
file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
447
448
symlink link link-id wibble/linktarget test@user-3 no
448
449
directory src src-id test@user-2 no
509
510
non-ascii commit \N{COPYRIGHT SIGN} me
511
directory . TREE_ROT test@user-1 no
512
directory . TREE_ROOT test@user-3 no
512
513
file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
513
514
directory src src-id test@user-2 no
514
515
file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no