/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: Canonical.com Patch Queue Manager
  • Date: 2011-05-20 11:07:31 UTC
  • mfrom: (5340.12.29 2.4-613247-test-cases)
  • Revision ID: pqm@pqm.ubuntu.com-20110520110731-8slefcqat6dr3asl
(jameinel) Bug #613247,
 clean up a bunch of test cases to avoid putting 'self' in the reference
 cycle. (John A Meinel)

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,
34
32
    )
35
33
 
77
75
                self.log_catcher = test_log.LogCatcher(*args, **kwargs)
78
76
                # Always return our own log formatter
79
77
                return self.log_catcher
 
78
        # Break cycle with closure over self on cleanup by removing method
 
79
        self.addCleanup(setattr, MyLogFormatter, "__new__", None)
80
80
 
81
81
        def getme(branch):
82
82
                # Always return our own log formatter class hijacking the
158
158
        self.make_linear_branch()
159
159
        self.assertLogRevnos(['-c1'], ['1'])
160
160
 
 
161
    def test_branch_revspec(self):
 
162
        foo = self.make_branch_and_tree('foo')
 
163
        bar = self.make_branch_and_tree('bar')
 
164
        self.build_tree(['foo/foo.txt', 'bar/bar.txt'])
 
165
        foo.add('foo.txt')
 
166
        bar.add('bar.txt')
 
167
        foo.commit(message='foo')
 
168
        bar.commit(message='bar')
 
169
        self.run_bzr('log -r branch:../bar', working_dir='foo')
 
170
        self.assertEqual([bar.branch.get_rev_id(1)],
 
171
                         [r.rev.revision_id
 
172
                          for r in self.get_captured_revisions()])
 
173
 
 
174
 
 
175
class TestLogExcludeCommonAncestry(TestLogWithLogCatcher):
 
176
 
 
177
    def test_exclude_common_ancestry_simple_revnos(self):
 
178
        self.make_linear_branch()
 
179
        self.assertLogRevnos(['-r1..3', '--exclude-common-ancestry'],
 
180
                             ['3', '2'])
 
181
 
161
182
 
162
183
class TestLogMergedLinearAncestry(TestLogWithLogCatcher):
163
184
 
167
188
        # stop calling run_bzr, there is no point) --vila 100118.
168
189
        builder = branchbuilder.BranchBuilder(self.get_transport())
169
190
        builder.start_series()
 
191
        # 1
 
192
        # | \
 
193
        # 2  1.1.1
 
194
        # | / |
 
195
        # 3  1.1.2
 
196
        # |   |
 
197
        # |  1.1.3
 
198
        # | / |
 
199
        # 4  1.1.4
 
200
        # | /
 
201
        # 5
 
202
 
170
203
        # mainline
171
204
        builder.build_snapshot('1', None, [
172
205
            ('add', ('', 'root-id', 'directory', ''))])
348
381
 
349
382
    def test_log_bad_message_re(self):
350
383
        """Bad --message argument gives a sensible message
351
 
        
 
384
 
352
385
        See https://bugs.launchpad.net/bzr/+bug/251352
353
386
        """
354
387
        self.make_minimal_branch()
355
388
        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)
 
389
        self.assertContainsRe(err, "ERROR.*Invalid pattern.*nothing to repeat")
 
390
        self.assertNotContainsRe(err, "Unprintable exception")
 
391
        self.assertEqual(out, '')
361
392
 
362
393
    def test_log_unsupported_timezone(self):
363
394
        self.make_linear_branch()
893
924
        self.prepare_tree()
894
925
        os.chdir("dir1")
895
926
        self.assertLogRevnos(['dir2', 'file5'], ['5', '3'])
 
927
 
 
928
 
 
929
class MainlineGhostTests(TestLogWithLogCatcher):
 
930
 
 
931
    def setUp(self):
 
932
        super(MainlineGhostTests, self).setUp()
 
933
        tree = self.make_branch_and_tree('')
 
934
        tree.set_parent_ids(["spooky"], allow_leftmost_as_ghost=True)
 
935
        tree.add('')
 
936
        tree.commit('msg1', rev_id='rev1')
 
937
        tree.commit('msg2', rev_id='rev2')
 
938
 
 
939
    def test_log_range(self):
 
940
        self.assertLogRevnos(["-r1..2"], ["2", "1"])
 
941
 
 
942
    def test_log_norange(self):
 
943
        self.assertLogRevnos([], ["2", "1"])
 
944
 
 
945
    def test_log_range_open_begin(self):
 
946
        raise tests.KnownFailure("log with ghosts fails. bug #726466")
 
947
        (stdout, stderr) = self.run_bzr(['log', '-r..2'], retcode=3)
 
948
        self.assertEqual(["2", "1"],
 
949
                         [r.revno for r in self.get_captured_revisions()])
 
950
        self.assertEquals("bzr: ERROR: Further revision history missing.", stderr)
 
951
 
 
952
    def test_log_range_open_end(self):
 
953
        self.assertLogRevnos(["-r1.."], ["2", "1"])