~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testtestament.py

- more testament development

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import difflib
20
20
import os
 
21
from sha import sha
21
22
import sys
22
23
 
23
24
from bzrlib.selftest import TestCaseInTempDir
37
38
                 rev_id='test@user-1')
38
39
        build_tree_contents([('hello', 'contents of hello file'),
39
40
                             ('src/', ),
40
 
                             ('src/foo.c', 'int main()\n{\n}')])
41
 
        b.add(['hello', 'src', 'src/foo.c'])
 
41
                             ('src/foo.c', 'int main()\n{\n}\n')])
 
42
        b.add(['hello', 'src', 'src/foo.c'],
 
43
              ['hello-id', 'src-id', 'foo.c-id'])
42
44
        b.commit(message='add files and directories',
43
45
                 timestamp=1129025483,
44
46
                 timezone=36000,
59
61
    def test_testment_text_form(self):
60
62
        """Conversion of testament to canonical text form."""
61
63
        t = Testament.from_revision(self.b, 'test@user-1')
62
 
        text_form = t.to_text_form_1()
 
64
        text_form = t.as_text()
63
65
        self.log('testament text form:\n' + text_form)
64
66
        expect = """\
65
67
bazaar-ng testament version 1
66
68
revision-id: test@user-1
67
69
committer: test@user
68
 
timestamp: 1129025423.0
 
70
timestamp: 1129025423
69
71
timezone: 0
70
 
entries: 0
71
72
parents:
72
73
message:
73
74
  initial null commit
78
79
    def test_testament_with_contents(self):
79
80
        """Testament containing a file and a directory."""
80
81
        t = Testament.from_revision(self.b, 'test@user-2')
81
 
        text_form = t.to_text_form_1()
 
82
        text_form = t.as_text()
82
83
        self.log('testament text form:\n' + text_form)
83
84
        expect = """\
84
85
bazaar-ng testament version 1
85
86
revision-id: test@user-2
86
87
committer: test@user
87
 
timestamp: 1129025483.0
 
88
timestamp: 1129025483
88
89
timezone: 36000
89
 
entries: 3
90
90
parents:
91
91
  test@user-1
92
92
message:
93
93
  add files and directories
94
94
inventory:
95
 
  file hello
96
 
  directory src
97
 
  file src/foo.c
 
95
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73
 
96
  directory src src-id
 
97
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24
98
98
"""
99
99
        self.assertEqualDiff(text_form, expect)
100
100
        actual_short = t.as_short_text()
101
101
        self.assertEqualDiff(actual_short, """\
102
102
bazaar-ng testament short form 1
103
103
revision test@user-2
104
 
sha1 e64f0a98937f8b0d2602ea5f521938752b90a430
105
 
""")
 
104
sha1 %s
 
105
""" % sha(expect).hexdigest())