~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2010-08-04 04:33:24 UTC
  • mto: This revision was merged to the branch mainline in revision 5390.
  • Revision ID: john@arbash-meinel.com-20100804043324-1ldc2v2w1kza7ox4
get into the nitty gritty for the _key_to_sha1 function.

It doesn't seem to help to op-out of the actual unhexlify call, so at least
that doesn't seem to be the performance overhead.
We get down to around 19.9us for _key_to_sha1 across 120 keys, which is
0.166us per key.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2006-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
25
25
    tests,
26
26
    workingtree,
27
27
    )
 
28
from bzrlib.diff import (
 
29
    DiffTree,
 
30
    format_registry as diff_format_registry,
 
31
    )
28
32
 
29
33
 
30
34
def subst_dates(string):
132
136
        out, err = self.run_bzr('diff -r 1..23..123', retcode=3,
133
137
            error_regexes=('one or two revision specifiers',))
134
138
 
 
139
    def test_diff_using_and_format(self):
 
140
        out, err = self.run_bzr('diff --format=default --using=mydi', retcode=3,
 
141
            error_regexes=('are mutually exclusive',))
 
142
 
135
143
    def test_diff_nonexistent_revision(self):
136
144
        out, err = self.run_bzr('diff -r 123', retcode=3,
137
145
            error_regexes=("Requested revision: '123' does not "
147
155
        self.assertContainsRe(err,
148
156
            "Requested revision: '1.1' does not exist in branch:")
149
157
 
 
158
    def test_diff_diff_options_and_using(self):
 
159
        out, err = self.run_bzr('diff --diff-options -wu --using /usr/bin/diff', retcode=3,
 
160
          error_regexes=('are mutually exclusive.',))
 
161
 
150
162
    def test_diff_unversioned(self):
151
163
        # Get an error when diffing a non-versioned file.
152
164
        # (Malone #3619)
297
309
        output = self.run_bzr('diff -r 1.. branch1', retcode=1)
298
310
        self.assertContainsRe(output[0], '\n\\-original line\n\\+repo line\n')
299
311
 
 
312
    def test_custom_format(self):
 
313
        class BooDiffTree(DiffTree):
 
314
 
 
315
            def show_diff(self, specific_files, extra_trees=None):
 
316
                self.to_file.write("BOO!\n")
 
317
                return super(BooDiffTree, self).show_diff(specific_files,
 
318
                    extra_trees)
 
319
 
 
320
        diff_format_registry.register("boo", BooDiffTree, 
 
321
            "Scary diff format")
 
322
        self.addCleanup(diff_format_registry.remove, "boo")
 
323
        self.make_example_branch()
 
324
        self.build_tree_contents([('hello', 'hello world!\n')])
 
325
        output = self.run_bzr('diff --format=boo', retcode=1)
 
326
        self.assertTrue("BOO!" in output[0])
300
327
 
301
328
class TestCheckoutDiff(TestDiff):
302
329