~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_log.py

Add bzrlib.pyutils, which has get_named_object, a wrapper around __import__.

This is used to replace various ad hoc implementations of the same logic,
notably the version used in registry's _LazyObjectGetter which had a bug when
getting a module without also getting a member.  And of course, this new
function has unit tests, unlike the replaced code.

This also adds a KnownHooksRegistry subclass to provide a more natural home for
some other logic.

I'm not thrilled about the name of the new module or the new functions, but it's
hard to think of good names for such generic functionality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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()