~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-17 18:13:57 UTC
  • mfrom: (5268.7.29 transport-segments)
  • Revision ID: pqm@pqm.ubuntu.com-20110817181357-y5q5eth1hk8bl3om
(jelmer) Allow specifying the colocated branch to use in the branch URL,
 and retrieving the branch name using ControlDir._get_selected_branch.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2013, 2016 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
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
24
24
    registry,
25
25
    revision,
26
26
    revisionspec,
 
27
    symbol_versioning,
27
28
    tests,
28
 
    gpg,
29
 
    trace,
30
29
    )
31
30
 
32
31
 
252
251
        wt.commit(message='add file1 and file2')
253
252
        self.run_bzr('branch parent child')
254
253
        os.unlink('child/file1')
255
 
        with file('child/file2', 'wb') as f: f.write('hello\n')
 
254
        file('child/file2', 'wb').write('hello\n')
256
255
        self.run_bzr(['commit', '-m', 'remove file1 and modify file2',
257
256
            'child'])
258
257
        os.chdir('parent')
283
282
        self.checkDelta(logentry.delta, added=['file1', 'file2'])
284
283
 
285
284
 
286
 
class TestFormatSignatureValidity(tests.TestCaseWithTransport):
287
 
    class UTFLoopbackGPGStrategy(gpg.LoopbackGPGStrategy):
288
 
        def verify(self, content, testament):
289
 
            return (gpg.SIGNATURE_VALID,
290
 
                u'UTF8 Test \xa1\xb1\xc1\xd1\xe1\xf1 <jrandom@example.com>')
291
 
 
292
 
    def has_signature_for_revision_id(self, revision_id):
293
 
        return True
294
 
 
295
 
    def get_signature_text(self, revision_id):
296
 
        return ''
297
 
 
298
 
    def test_format_signature_validity_utf(self):
299
 
        """Check that GPG signatures containing UTF-8 names are formatted
300
 
        correctly."""
301
 
        # Monkey patch to use our UTF-8 generating GPGStrategy
302
 
        self.overrideAttr(gpg, 'GPGStrategy', self.UTFLoopbackGPGStrategy)
303
 
        wt = self.make_branch_and_tree('.')
304
 
        revid = wt.commit('empty commit')
305
 
        repo = wt.branch.repository
306
 
        # Monkey patch out checking if this rev is actually signed, since we
307
 
        # can't sign it without a heavier TestCase and LoopbackGPGStrategy
308
 
        # doesn't care anyways.
309
 
        self.overrideAttr(repo, 'has_signature_for_revision_id',
310
 
                self.has_signature_for_revision_id)
311
 
        self.overrideAttr(repo, 'get_signature_text', self.get_signature_text)
312
 
        out = log.format_signature_validity(revid, repo)
313
 
        self.assertEqual(
314
 
u'valid signature from UTF8 Test \xa1\xb1\xc1\xd1\xe1\xf1 <jrandom@example.com>',
315
 
                out)
316
 
 
317
 
 
318
285
class TestShortLogFormatter(TestCaseForLogFormatter):
319
286
 
320
287
    def test_trailing_newlines(self):
356
323
    1 Joe Foo\t2005-11-22
357
324
      rev-1
358
325
 
359
 
Use --include-merged or -n0 to see merged revisions.
 
326
Use --include-merges or -n0 to see merged revisions.
360
327
""",
361
328
            wt.branch, log.ShortLogFormatter,
362
329
            formatter_kwargs=dict(show_advice=True))
1343
1310
class TestLogWithBugs(TestCaseForLogFormatter, TestLogMixin):
1344
1311
 
1345
1312
    def setUp(self):
1346
 
        super(TestLogWithBugs, self).setUp()
 
1313
        TestCaseForLogFormatter.setUp(self)
1347
1314
        log.properties_handler_registry.register(
1348
1315
            'bugs_properties_handler',
1349
1316
            log._bugs_properties_handler)
1368
1335
        self.assertFormatterResult("""\
1369
1336
------------------------------------------------------------
1370
1337
revno: 2
1371
 
fixes bugs: test://bug/id test://bug/2
 
1338
fixes bug(s): test://bug/id test://bug/2
1372
1339
author: Joe Bar <joe@bar.com>
1373
1340
committer: Joe Foo <joe@foo.com>
1374
1341
branch nick: work
1379
1346
  message
1380
1347
------------------------------------------------------------
1381
1348
revno: 1
1382
 
fixes bug: test://bug/id
 
1349
fixes bug(s): test://bug/id
1383
1350
committer: Joe Foo <joe@foo.com>
1384
1351
branch nick: work
1385
1352
timestamp: Tue 2005-11-22 00:00:00 +0000
1392
1359
        tree = self.make_commits_with_bugs()
1393
1360
        self.assertFormatterResult("""\
1394
1361
    2 Joe Bar\t2005-11-22
1395
 
      fixes bugs: test://bug/id test://bug/2
 
1362
      fixes bug(s): test://bug/id test://bug/2
1396
1363
      multiline
1397
1364
      log
1398
1365
      message
1399
1366
 
1400
1367
    1 Joe Foo\t2005-11-22
1401
 
      fixes bug: test://bug/id
 
1368
      fixes bug(s): test://bug/id
1402
1369
      simple log message
1403
1370
 
1404
1371
""",
1423
1390
class TestLogForAuthors(TestCaseForLogFormatter):
1424
1391
 
1425
1392
    def setUp(self):
1426
 
        super(TestLogForAuthors, self).setUp()
 
1393
        TestCaseForLogFormatter.setUp(self)
1427
1394
        self.wt = self.make_standard_commit('nicky',
1428
1395
            authors=['John Doe <jdoe@example.com>',
1429
1396
                     'Jane Rey <jrey@example.com>'])
1603
1570
    def assertLogRevnos(self, expected_revnos, b, start, end,
1604
1571
                        exclude_common_ancestry, generate_merge_revisions=True):
1605
1572
        # FIXME: the layering in log makes it hard to test intermediate levels,
1606
 
        # I wish adding filters with their parameters was easier...
 
1573
        # I wish adding filters with their parameters were easier...
1607
1574
        # -- vila 20100413
1608
1575
        iter_revs = log._calc_view_revisions(
1609
1576
            b, start, end, direction='reverse',
1660
1627
        request = log.make_log_request_dict(limit=10)
1661
1628
        log.Logger(b, request).show(log_formatter)
1662
1629
        # should have all three revisions:
1663
 
        self.assertEqual(len(log_formatter.revisions), 3)
 
1630
        self.assertEquals(len(log_formatter.revisions), 3)
1664
1631
 
1665
1632
        del log_formatter
1666
1633
        log_formatter = LogCatcher()
1668
1635
        request = log.make_log_request_dict(limit=10, levels=1)
1669
1636
        log.Logger(b, request).show(log_formatter)
1670
1637
        # should now only have 2 revisions:
1671
 
        self.assertEqual(len(log_formatter.revisions), 2)
1672
 
 
 
1638
        self.assertEquals(len(log_formatter.revisions), 2)