~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-10 20:03:44 UTC
  • mto: This revision was merged to the branch mainline in revision 5376.
  • Revision ID: john@arbash-meinel.com-20100810200344-6muerwvkafqu7w47
Rework things a bit so the logic can be shared.

It turns out that some of the peak memory is actually during the inventory
to string to bundle translations. So re-use the refcount logic there.
This actually does show a decrease in peak memory.
Specifically 'cd bzr.dev; bzr send ../2.2' drops from 221MB peak to 156MB.

We don't speed anything up (16.5s both ways), but peak memory is quite
a bit better.

Show diffs side-by-side

added added

removed removed

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