/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/blackbox/test_log.py

  • Committer: Andrew Bennetts
  • Date: 2011-07-12 23:33:11 UTC
  • mto: (6015.3.2 2.4)
  • mto: This revision was merged to the branch mainline in revision 6027.
  • Revision ID: andrew.bennetts@canonical.com-20110712233311-o5j4bvptl3kvw0l6
Backport lp:bzr r6020: Speed up TestCaseWithMemoryTransport._check_safety_net by reading the dirstate file directly rather than using WorkingTree.open().

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from itertools import izip
21
21
import os
22
 
import re
23
22
 
24
23
from bzrlib import (
25
24
    branchbuilder,
29
28
    tests,
30
29
    )
31
30
from bzrlib.tests import (
32
 
    script,
33
31
    test_log,
 
32
    features,
34
33
    )
35
34
 
36
35
 
77
76
                self.log_catcher = test_log.LogCatcher(*args, **kwargs)
78
77
                # Always return our own log formatter
79
78
                return self.log_catcher
 
79
        # Break cycle with closure over self on cleanup by removing method
 
80
        self.addCleanup(setattr, MyLogFormatter, "__new__", None)
80
81
 
81
82
        def getme(branch):
82
83
                # Always return our own log formatter class hijacking the
158
159
        self.make_linear_branch()
159
160
        self.assertLogRevnos(['-c1'], ['1'])
160
161
 
 
162
    def test_branch_revspec(self):
 
163
        foo = self.make_branch_and_tree('foo')
 
164
        bar = self.make_branch_and_tree('bar')
 
165
        self.build_tree(['foo/foo.txt', 'bar/bar.txt'])
 
166
        foo.add('foo.txt')
 
167
        bar.add('bar.txt')
 
168
        foo.commit(message='foo')
 
169
        bar.commit(message='bar')
 
170
        self.run_bzr('log -r branch:../bar', working_dir='foo')
 
171
        self.assertEqual([bar.branch.get_rev_id(1)],
 
172
                         [r.rev.revision_id
 
173
                          for r in self.get_captured_revisions()])
 
174
 
 
175
 
 
176
class TestLogExcludeCommonAncestry(TestLogWithLogCatcher):
 
177
 
 
178
    def test_exclude_common_ancestry_simple_revnos(self):
 
179
        self.make_linear_branch()
 
180
        self.assertLogRevnos(['-r1..3', '--exclude-common-ancestry'],
 
181
                             ['3', '2'])
 
182
 
161
183
 
162
184
class TestLogMergedLinearAncestry(TestLogWithLogCatcher):
163
185
 
167
189
        # stop calling run_bzr, there is no point) --vila 100118.
168
190
        builder = branchbuilder.BranchBuilder(self.get_transport())
169
191
        builder.start_series()
 
192
        # 1
 
193
        # | \
 
194
        # 2  1.1.1
 
195
        # | / |
 
196
        # 3  1.1.2
 
197
        # |   |
 
198
        # |  1.1.3
 
199
        # | / |
 
200
        # 4  1.1.4
 
201
        # | /
 
202
        # 5
 
203
 
170
204
        # mainline
171
205
        builder.build_snapshot('1', None, [
172
206
            ('add', ('', 'root-id', 'directory', ''))])
348
382
 
349
383
    def test_log_bad_message_re(self):
350
384
        """Bad --message argument gives a sensible message
351
 
        
 
385
 
352
386
        See https://bugs.launchpad.net/bzr/+bug/251352
353
387
        """
354
388
        self.make_minimal_branch()
355
389
        out, err = self.run_bzr(['log', '-m', '*'], retcode=3)
356
 
        self.assertEqual("bzr: ERROR: Invalid regular expression"
357
 
            " in log message filter"
358
 
            ": '*'"
359
 
            ": nothing to repeat\n", err)
360
 
        self.assertEqual('', out)
 
390
        self.assertContainsRe(err, "ERROR.*Invalid pattern.*nothing to repeat")
 
391
        self.assertNotContainsRe(err, "Unprintable exception")
 
392
        self.assertEqual(out, '')
361
393
 
362
394
    def test_log_unsupported_timezone(self):
363
395
        self.make_linear_branch()
411
443
        self.assertContainsRe(log, r'tags: tag1')
412
444
 
413
445
 
 
446
class TestLogSignatures(TestLog):
 
447
 
 
448
    def test_log_with_signatures(self):
 
449
        self.requireFeature(features.gpgme)
 
450
 
 
451
        tree = self.make_linear_branch(format='dirstate-tags')
 
452
 
 
453
        log = self.run_bzr("log --signatures")[0]
 
454
        self.assertTrue('signature: no signature' in log)
 
455
 
 
456
    def test_log_without_signatures(self):
 
457
        self.requireFeature(features.gpgme)
 
458
 
 
459
        tree = self.make_linear_branch(format='dirstate-tags')
 
460
 
 
461
        log = self.run_bzr("log")[0]
 
462
        self.assertFalse('signature: no signature' in log)
 
463
 
 
464
 
414
465
class TestLogVerbose(TestLog):
415
466
 
416
467
    def setUp(self):
432
483
    def test_log_short_verbose(self):
433
484
        self.assertUseShortDeltaFormat(['log', '--short', '-v'])
434
485
 
 
486
    def test_log_s_verbose(self):
 
487
        self.assertUseShortDeltaFormat(['log', '-S', '-v'])
 
488
 
435
489
    def test_log_short_verbose_verbose(self):
436
490
        self.assertUseLongDeltaFormat(['log', '--short', '-vv'])
437
491
 
893
947
        self.prepare_tree()
894
948
        os.chdir("dir1")
895
949
        self.assertLogRevnos(['dir2', 'file5'], ['5', '3'])
 
950
 
 
951
 
 
952
class MainlineGhostTests(TestLogWithLogCatcher):
 
953
 
 
954
    def setUp(self):
 
955
        super(MainlineGhostTests, self).setUp()
 
956
        tree = self.make_branch_and_tree('')
 
957
        tree.set_parent_ids(["spooky"], allow_leftmost_as_ghost=True)
 
958
        tree.add('')
 
959
        tree.commit('msg1', rev_id='rev1')
 
960
        tree.commit('msg2', rev_id='rev2')
 
961
 
 
962
    def test_log_range(self):
 
963
        self.assertLogRevnos(["-r1..2"], ["2", "1"])
 
964
 
 
965
    def test_log_norange(self):
 
966
        self.assertLogRevnos([], ["2", "1"])
 
967
 
 
968
    def test_log_range_open_begin(self):
 
969
        raise tests.KnownFailure("log with ghosts fails. bug #726466")
 
970
        (stdout, stderr) = self.run_bzr(['log', '-r..2'], retcode=3)
 
971
        self.assertEqual(["2", "1"],
 
972
                         [r.revno for r in self.get_captured_revisions()])
 
973
        self.assertEquals("bzr: ERROR: Further revision history missing.", stderr)
 
974
 
 
975
    def test_log_range_open_end(self):
 
976
        self.assertLogRevnos(["-r1.."], ["2", "1"])