~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_testament.py

Late bind to PatienceSequenceMatcher to allow plugin to override.

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, StrictTestament
 
27
from bzrlib.testament import Testament
28
28
from bzrlib.trace import mutter
29
 
from bzrlib.transform import TreeTransform
30
29
from bzrlib.osutils import has_symlinks
31
30
 
32
31
 
47
46
                             ('src/foo.c', 'int main()\n{\n}\n')])
48
47
        self.wt.add(['hello', 'src', 'src/foo.c'],
49
48
                             ['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()
54
49
        self.wt.commit(message='add files and directories',
55
50
                 timestamp=1129025483,
56
51
                 timezone=36000,
75
70
        self.log('testament text form:\n' + text_form)
76
71
        self.assertEqual(text_form, REV_1_TESTAMENT)
77
72
 
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
 
 
85
73
    def test_testament_with_contents(self):
86
74
        """Testament containing a file and a directory."""
87
75
        t = Testament.from_revision(self.b.repository, 'test@user-2')
91
79
        actual_short = t.as_short_text()
92
80
        self.assertEqualDiff(actual_short, REV_2_SHORT)
93
81
 
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
 
 
103
82
    def test_testament_command(self):
104
83
        """Testament containing a file and a directory."""
105
84
        out, err = self.run_bzr_captured(['testament', '--long'])
112
91
        self.assertEqualDiff(err, '')
113
92
        self.assertEqualDiff(out, REV_1_SHORT)
114
93
 
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
 
 
121
94
    def test_testament_symlinks(self):
122
95
        """Testament containing symlink (where possible)"""
123
96
        if not has_symlinks():
135
108
    def test_testament_revprops(self):
136
109
        """Testament to revision with extra properties"""
137
110
        props = dict(flavor='sour cherry\ncream cheese',
138
 
                     size='medium',
139
 
                     empty='',
140
 
                    )
 
111
                     size='medium')
141
112
        self.wt.commit(message='revision with properties',
142
113
                      timestamp=1129025493,
143
114
                      timezone=36000,
182
153
    test branch
183
154
"""
184
155
 
185
 
REV_1_STRICT_TESTAMENT = """\
186
 
bazaar-ng testament version 2.1
187
 
revision-id: test@user-1
188
 
committer: test@user
189
 
timestamp: 1129025423
190
 
timezone: 0
191
 
parents:
192
 
message:
193
 
  initial null commit
194
 
inventory:
195
 
properties:
196
 
  branch-nick:
197
 
    test branch
198
 
"""
199
 
 
200
 
 
201
156
REV_1_SHORT = """\
202
157
bazaar-ng testament short form 1
203
158
revision-id: test@user-1
205
160
""" % sha(REV_1_TESTAMENT).hexdigest()
206
161
 
207
162
 
208
 
REV_1_SHORT_STRICT = """\
209
 
bazaar-ng testament short form 2.1
210
 
revision-id: test@user-1
211
 
sha1: %s
212
 
""" % sha(REV_1_STRICT_TESTAMENT).hexdigest()
213
 
 
214
 
 
215
163
REV_2_TESTAMENT = """\
216
164
bazaar-ng testament version 1
217
165
revision-id: test@user-2
232
180
"""
233
181
 
234
182
 
235
 
REV_2_STRICT_TESTAMENT = """\
236
 
bazaar-ng testament version 2.1
237
 
revision-id: test@user-2
238
 
committer: test@user
239
 
timestamp: 1129025483
240
 
timezone: 36000
241
 
parents:
242
 
  test@user-1
243
 
message:
244
 
  add files and directories
245
 
inventory:
246
 
  file hello hello-id 34dd0ac19a24bf80c4d33b5c8960196e8d8d1f73 test@user-2 yes
247
 
  directory src src-id test@user-2 no
248
 
  file src/foo.c foo.c-id a2a049c20f908ae31b231d98779eb63c66448f24 test@user-2 no
249
 
properties:
250
 
  branch-nick:
251
 
    test branch
252
 
"""
253
 
 
254
 
 
255
183
REV_2_SHORT = """\
256
184
bazaar-ng testament short form 1
257
185
revision-id: test@user-2
259
187
""" % sha(REV_2_TESTAMENT).hexdigest()
260
188
 
261
189
 
262
 
REV_2_SHORT_STRICT = """\
263
 
bazaar-ng testament short form 2.1
264
 
revision-id: test@user-2
265
 
sha1: %s
266
 
""" % sha(REV_2_STRICT_TESTAMENT).hexdigest()
267
 
 
268
 
 
269
190
REV_PROPS_TESTAMENT = """\
270
191
bazaar-ng testament version 1
271
192
revision-id: test@user-3
283
204
properties:
284
205
  branch-nick:
285
206
    test branch
286
 
  empty:
287
207
  flavor:
288
208
    sour cherry
289
209
    cream cheese