~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012 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
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
"""Black-box tests for bzr diff."""
 
18
"""Black-box tests for bzr diff.
 
19
"""
19
20
 
20
21
import os
21
22
import re
287
288
        self.example_branch2()
288
289
        self.build_tree_contents([('branch1/file1', 'new line')])
289
290
        os.mkdir('branch1/dir1')
290
 
        output = self.run_bzr('diff -r 1..', retcode=1,
291
 
                              working_dir='branch1/dir1')
 
291
        os.chdir('branch1/dir1')
 
292
        output = self.run_bzr('diff -r 1..', retcode=1)
292
293
        self.assertContainsRe(output[0], '\n\\-original line\n\\+new line\n')
293
294
 
294
295
    def test_diff_across_rename(self):
315
316
                return super(BooDiffTree, self).show_diff(specific_files,
316
317
                    extra_trees)
317
318
 
318
 
        diff_format_registry.register("boo", BooDiffTree, "Scary diff format")
 
319
        diff_format_registry.register("boo", BooDiffTree, 
 
320
            "Scary diff format")
319
321
        self.addCleanup(diff_format_registry.remove, "boo")
320
322
        self.make_example_branch()
321
323
        self.build_tree_contents([('hello', 'hello world!\n')])
322
324
        output = self.run_bzr('diff --format=boo', retcode=1)
323
325
        self.assertTrue("BOO!" in output[0])
324
 
        output = self.run_bzr('diff -Fboo', retcode=1)
325
 
        self.assertTrue("BOO!" in output[0])
326
 
 
327
326
 
328
327
class TestCheckoutDiff(TestDiff):
329
328
 
341
340
        return tree
342
341
 
343
342
    def example_branches(self):
344
 
        branch1_tree, branch2_tree = super(TestCheckoutDiff,
345
 
                                           self).example_branches()
 
343
        branch1_tree, branch2_tree = super(TestCheckoutDiff, self).example_branches()
346
344
        os.mkdir('checkouts')
347
345
        branch1_tree = branch1_tree.branch.create_checkout('checkouts/branch1')
348
346
        branch2_tree = branch2_tree.branch.create_checkout('checkouts/branch2')
388
386
        # subprocess.py that we had to workaround).
389
387
        # However, if 'diff' may not be available
390
388
        self.make_example_branch()
391
 
        out, err = self.run_bzr_subprocess(
392
 
            'diff -Oprogress_bar=none -r 1 --diff-options -ub',
393
 
            universal_newlines=True,
394
 
            retcode=None)
 
389
        # this will be automatically restored by the base bzr test class
 
390
        os.environ['BZR_PROGRESS_BAR'] = 'none'
 
391
        out, err = self.run_bzr_subprocess('diff -r 1 --diff-options -ub',
 
392
                                           universal_newlines=True,
 
393
                                           retcode=None)
395
394
        if 'Diff is not installed on this machine' in err:
396
395
            raise tests.TestSkipped("No external 'diff' is available")
397
396
        self.assertEqual('', err)