/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_annotate.py

  • Committer: Robert Collins
  • Date: 2008-02-13 03:30:01 UTC
  • mfrom: (3221 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3224.
  • Revision ID: robertc@robertcollins.net-20080213033001-rw70ul0zb02ph856
Merge to fix conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
149
149
        tree1.commit('merge 2', rev_id='rev-3',
150
150
                     committer='sal@foo.com',
151
151
                     timestamp=1166046003.00, timezone=0)
 
152
        tree1.lock_read()
 
153
        self.addCleanup(tree1.unlock)
152
154
        return tree1, tree2
153
155
 
154
156
    def create_deeply_merged_trees(self):
160
162
         |      |          |
161
163
         +------+          |
162
164
         |      |          |
163
 
        rev-3  rev-1_1_2  rev-1_1_1_1_1 --+
 
165
        rev-3  rev-1_1_2  rev-1_2_1 ------+
164
166
         |      |          |              |
165
167
         +------+          |              |
166
168
         |                 |              |
167
 
        rev-4             rev-1_1_1_1_2  rev-1_1_1_1_1_1_1
 
169
        rev-4             rev-1_2_2  rev-1_3_1
168
170
         |                 |              |
169
171
         +-----------------+              |
170
172
         |                                |
175
177
        rev-6
176
178
        """
177
179
        tree1, tree2 = self.create_merged_trees()
 
180
        tree1.unlock()
178
181
 
179
182
        tree3 = tree2.bzrdir.clone('tree3').open_workingtree()
180
183
 
183
186
        tree1.commit('noop merge', rev_id='rev-4')
184
187
 
185
188
        self.build_tree_contents([('tree3/a', 'first\nthird\nfourth\n')])
186
 
        tree3.commit('four', rev_id='rev-1_1_1_1_1',
 
189
        tree3.commit('four', rev_id='rev-1_2_1',
187
190
                     committer='jerry@foo.com',
188
191
                     timestamp=1166046003.00, timezone=0)
189
192
 
190
193
        tree4 = tree3.bzrdir.clone('tree4').open_workingtree()
191
194
 
192
 
        tree3.commit('noop', rev_id='rev-1_1_1_1_2',
 
195
        tree3.commit('noop', rev_id='rev-1_2_2',
193
196
                     committer='jerry@foo.com',
194
197
                     timestamp=1166046004.00, timezone=0)
195
198
        self.assertEqual(0, tree1.merge_from_branch(tree3.branch))
197
200
 
198
201
        self.build_tree_contents([('tree4/a',
199
202
                                   'first\nthird\nfourth\nfifth\nsixth\n')])
200
 
        tree4.commit('five and six', rev_id='rev-1_1_1_1_1_1_1',
 
203
        tree4.commit('five and six', rev_id='rev-1_3_1',
201
204
                     committer='george@foo.com',
202
205
                     timestamp=1166046005.00, timezone=0)
203
206
        self.assertEqual(0, tree1.merge_from_branch(tree4.branch))
204
207
        tree1.commit('merge five and six', rev_id='rev-6')
 
208
        tree1.lock_read()
205
209
        return tree1
206
210
 
207
211
    def test_annotate_shows_dotted_revnos(self):
222
226
        sio = StringIO()
223
227
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
224
228
                               to_file=sio, verbose=False, full=False)
225
 
        self.assertEqualDiff('1            joe@foo | first\n'
226
 
                             '2            joe@foo | second\n'
227
 
                             '1.1.1        barry@f | third\n'
228
 
                             '1.1.1.1.1    jerry@f | fourth\n'
229
 
                             '1.1.1.1.1.1> george@ | fifth\n'
230
 
                             '                     | sixth\n',
 
229
        self.assertEqualDiff('1     joe@foo | first\n'
 
230
                             '2     joe@foo | second\n'
 
231
                             '1.1.1 barry@f | third\n'
 
232
                             '1.2.1 jerry@f | fourth\n'
 
233
                             '1.3.1 george@ | fifth\n'
 
234
                             '              | sixth\n',
231
235
                             sio.getvalue())
232
236
 
233
237
        sio = StringIO()
234
238
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
235
239
                               to_file=sio, verbose=False, full=True)
236
 
        self.assertEqualDiff('1            joe@foo | first\n'
237
 
                             '2            joe@foo | second\n'
238
 
                             '1.1.1        barry@f | third\n'
239
 
                             '1.1.1.1.1    jerry@f | fourth\n'
240
 
                             '1.1.1.1.1.1> george@ | fifth\n'
241
 
                             '1.1.1.1.1.1> george@ | sixth\n',
 
240
        self.assertEqualDiff('1     joe@foo | first\n'
 
241
                             '2     joe@foo | second\n'
 
242
                             '1.1.1 barry@f | third\n'
 
243
                             '1.2.1 jerry@f | fourth\n'
 
244
                             '1.3.1 george@ | fifth\n'
 
245
                             '1.3.1 george@ | sixth\n',
242
246
                             sio.getvalue())
243
247
 
244
248
        # verbose=True shows everything, the full revno, user id, and date
245
249
        sio = StringIO()
246
250
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
247
251
                               to_file=sio, verbose=True, full=False)
248
 
        self.assertEqualDiff('1             joe@foo.com    20061213 | first\n'
249
 
                             '2             joe@foo.com    20061213 | second\n'
250
 
                             '1.1.1         barry@foo.com  20061213 | third\n'
251
 
                             '1.1.1.1.1     jerry@foo.com  20061213 | fourth\n'
252
 
                             '1.1.1.1.1.1.1 george@foo.com 20061213 | fifth\n'
253
 
                             '                                      | sixth\n',
 
252
        self.assertEqualDiff('1     joe@foo.com    20061213 | first\n'
 
253
                             '2     joe@foo.com    20061213 | second\n'
 
254
                             '1.1.1 barry@foo.com  20061213 | third\n'
 
255
                             '1.2.1 jerry@foo.com  20061213 | fourth\n'
 
256
                             '1.3.1 george@foo.com 20061213 | fifth\n'
 
257
                             '                              | sixth\n',
254
258
                             sio.getvalue())
255
259
 
256
260
        sio = StringIO()
257
261
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
258
262
                               to_file=sio, verbose=True, full=True)
259
 
        self.assertEqualDiff('1             joe@foo.com    20061213 | first\n'
260
 
                             '2             joe@foo.com    20061213 | second\n'
261
 
                             '1.1.1         barry@foo.com  20061213 | third\n'
262
 
                             '1.1.1.1.1     jerry@foo.com  20061213 | fourth\n'
263
 
                             '1.1.1.1.1.1.1 george@foo.com 20061213 | fifth\n'
264
 
                             '1.1.1.1.1.1.1 george@foo.com 20061213 | sixth\n',
 
263
        self.assertEqualDiff('1     joe@foo.com    20061213 | first\n'
 
264
                             '2     joe@foo.com    20061213 | second\n'
 
265
                             '1.1.1 barry@foo.com  20061213 | third\n'
 
266
                             '1.2.1 jerry@foo.com  20061213 | fourth\n'
 
267
                             '1.3.1 george@foo.com 20061213 | fifth\n'
 
268
                             '1.3.1 george@foo.com 20061213 | sixth\n',
265
269
                             sio.getvalue())
266
270
 
267
271
    def test_annotate_uses_branch_context(self):
273
277
        tree1 = self.create_deeply_merged_trees()
274
278
 
275
279
        sio = StringIO()
276
 
        annotate.annotate_file(tree1.branch, 'rev-1_1_1_1_1_1_1', 'a-id',
 
280
        annotate.annotate_file(tree1.branch, 'rev-1_3_1', 'a-id',
277
281
                               to_file=sio, verbose=False, full=False)
278
 
        self.assertEqualDiff('1            joe@foo | first\n'
279
 
                             '1.1.1        barry@f | third\n'
280
 
                             '1.1.1.1.1    jerry@f | fourth\n'
281
 
                             '1.1.1.1.1.1> george@ | fifth\n'
282
 
                             '                     | sixth\n',
 
282
        self.assertEqualDiff('1     joe@foo | first\n'
 
283
                             '1.1.1 barry@f | third\n'
 
284
                             '1.2.1 jerry@f | fourth\n'
 
285
                             '1.3.1 george@ | fifth\n'
 
286
                             '              | sixth\n',
283
287
                             sio.getvalue())
284
288
 
285
289
    def test_annotate_show_ids(self):
290
294
                               to_file=sio, show_ids=True, full=False)
291
295
 
292
296
        # It looks better with real revision ids :)
293
 
        self.assertEqualDiff('            rev-1 | first\n'
294
 
                             '            rev-2 | second\n'
295
 
                             '        rev-1_1_1 | third\n'
296
 
                             '    rev-1_1_1_1_1 | fourth\n'
297
 
                             'rev-1_1_1_1_1_1_1 | fifth\n'
298
 
                             '                  | sixth\n',
 
297
        self.assertEqualDiff('    rev-1 | first\n'
 
298
                             '    rev-2 | second\n'
 
299
                             'rev-1_1_1 | third\n'
 
300
                             'rev-1_2_1 | fourth\n'
 
301
                             'rev-1_3_1 | fifth\n'
 
302
                             '          | sixth\n',
299
303
                             sio.getvalue())
300
304
 
301
305
        sio = StringIO()
302
306
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
303
307
                               to_file=sio, show_ids=True, full=True)
304
308
 
305
 
        self.assertEqualDiff('            rev-1 | first\n'
306
 
                             '            rev-2 | second\n'
307
 
                             '        rev-1_1_1 | third\n'
308
 
                             '    rev-1_1_1_1_1 | fourth\n'
309
 
                             'rev-1_1_1_1_1_1_1 | fifth\n'
310
 
                             'rev-1_1_1_1_1_1_1 | sixth\n',
 
309
        self.assertEqualDiff('    rev-1 | first\n'
 
310
                             '    rev-2 | second\n'
 
311
                             'rev-1_1_1 | third\n'
 
312
                             'rev-1_2_1 | fourth\n'
 
313
                             'rev-1_3_1 | fifth\n'
 
314
                             'rev-1_3_1 | sixth\n',
311
315
                             sio.getvalue())
312
316
 
313
317
    def test_annotate_unicode_author(self):
325
329
                     committer=u'p\xe9rez',
326
330
                     timestamp=1166046000.00, timezone=0)
327
331
 
 
332
        tree1.lock_read()
 
333
        self.addCleanup(tree1.unlock)
328
334
        # this passes if no exception is raised
329
335
        to_file = StringIO()
330
336
        annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
362
368
                     author='Author <author@example.com>',
363
369
                     timestamp=1166046000.00, timezone=0)
364
370
 
 
371
        tree1.lock_read()
 
372
        self.addCleanup(tree1.unlock)
365
373
        to_file = StringIO()
366
374
        annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
367
375
        self.assertEqual('1   committ | hello\n', to_file.getvalue())