~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: 2006-04-13 22:37:15 UTC
  • mfrom: (1658.1.10 bzr.mbp.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060413223715-b826d3cb591fed82
(mbp) fix #38331, #3619

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 by Canonical Ltd
2
 
# -*- coding: utf-8 -*-
 
1
# Copyright (C) 2005, 2006 by Canonical Ltd
3
2
 
4
3
# This program is free software; you can redistribute it and/or modify
5
4
# it under the terms of the GNU General Public License as published by
27
26
 
28
27
 
29
28
class TestDiff(ExternalBase):
30
 
    def example_branch(test):
 
29
 
 
30
    def make_example_branch(test):
31
31
        # FIXME: copied from test_too_much -- share elsewhere?
32
32
        test.runbzr('init')
33
33
        file('hello', 'wt').write('foo')
38
38
        test.runbzr('commit -m setup goodbye')
39
39
 
40
40
    def test_diff(self):
41
 
        self.example_branch()
 
41
        self.make_example_branch()
42
42
        file('hello', 'wt').write('hello world!')
43
43
        self.runbzr('commit -m fixing hello')
44
44
        output = self.runbzr('diff -r 2..3', backtick=1, retcode=1)
50
50
        os.unlink('moo')
51
51
        self.runbzr('diff')
52
52
 
 
53
    def test_diff_nonexistent(self):
 
54
        # Get an error from a file that does not exist at all
 
55
        # (Malone #3619)
 
56
        self.make_example_branch()
 
57
        out, err = self.runbzr('diff does-not-exist', retcode=3)
 
58
        self.assertContainsRe(err, 'not versioned.*does-not-exist')
 
59
 
 
60
    def test_diff_unversioned(self):
 
61
        # Get an error when diffing a non-versioned file.
 
62
        # (Malone #3619)
 
63
        self.make_example_branch()
 
64
        self.build_tree(['unversioned-file'])
 
65
        out, err = self.runbzr('diff unversioned-file', retcode=3)
 
66
        self.assertContainsRe(err, 'not versioned.*unversioned-file')
 
67
 
 
68
    # TODO: What should diff say for a file deleted in working tree?
 
69
 
53
70
    def example_branches(self):
54
71
        self.build_tree(['branch1/', 'branch1/file'], line_endings='binary')
55
72
        self.capture('init branch1')
102
119
 
103
120
class TestCheckoutDiff(TestDiff):
104
121
 
105
 
    def example_branch(self):
106
 
        super(TestCheckoutDiff, self).example_branch()
 
122
    def make_example_branch(self):
 
123
        super(TestCheckoutDiff, self).make_example_branch()
107
124
        self.runbzr('checkout . checkout')
108
125
        os.chdir('checkout')
109
126
 
120
137
        self.runbzr('checkout branch2 checkouts/branch2')
121
138
        os.chdir('checkouts')
122
139
 
 
140
 
123
141
class TestDiffLabels(TestDiff):
124
142
 
125
143
    def test_diff_label_removed(self):
126
 
        super(TestDiffLabels, self).example_branch()
 
144
        super(TestDiffLabels, self).make_example_branch()
127
145
        self.runbzr('remove hello')
128
146
        diff = self.run_bzr_captured(['diff'], retcode=1)
129
147
        self.assertTrue("=== removed file 'a/hello'" in diff[0])
130
148
 
131
149
    def test_diff_label_added(self):
132
 
        super(TestDiffLabels, self).example_branch()
 
150
        super(TestDiffLabels, self).make_example_branch()
133
151
        file('barbar', 'wt').write('barbar')
134
152
        self.runbzr('add barbar')
135
153
        diff = self.run_bzr_captured(['diff'], retcode=1)
136
154
        self.assertTrue("=== added file 'b/barbar'" in diff[0])
137
155
 
138
156
    def test_diff_label_modified(self):
139
 
        super(TestDiffLabels, self).example_branch()
 
157
        super(TestDiffLabels, self).make_example_branch()
140
158
        file('hello', 'wt').write('barbar')
141
159
        diff = self.run_bzr_captured(['diff'], retcode=1)
142
160
        self.assertTrue("=== modified file 'a/hello'" in diff[0])
143
161
 
144
162
    def test_diff_label_renamed(self):
145
 
        super(TestDiffLabels, self).example_branch()
 
163
        super(TestDiffLabels, self).make_example_branch()
146
164
        self.runbzr('rename hello gruezi')
147
165
        diff = self.run_bzr_captured(['diff'], retcode=1)
148
166
        self.assertTrue("=== renamed file 'a/hello' => 'b/gruezi'" in diff[0])