~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Haw Loeung (hloeung)
  • Date: 2012-07-24 12:53:36 UTC
  • mfrom: (6541 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6542.
  • Revision ID: haw.loeung@canonical.com-20120724125336-r3wzxm02lyec7jm6
[hloeung] Merged with upstream resolving conflicts.

Show diffs side-by-side

added added

removed removed

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