~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2006-04-13 05:37:24 UTC
  • mto: This revision was merged to the branch mainline in revision 1662.
  • Revision ID: mbp@sourcefrog.net-20060413053724-8c0053ac31492637
Give an error for bzr diff on an nonexistent file (Malone #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
        # should be an error that refers to the file that causes a problem
 
59
        self.assertContainsRe(err, 'not versioned.*does-not-exist')
 
60
 
 
61
        # TODO: Get an error diffing a file that is not versioned
 
62
        # TODO: How to handle a file deleted in working tree?
 
63
 
53
64
    def example_branches(self):
54
65
        self.build_tree(['branch1/', 'branch1/file'], line_endings='binary')
55
66
        self.capture('init branch1')
102
113
 
103
114
class TestCheckoutDiff(TestDiff):
104
115
 
105
 
    def example_branch(self):
106
 
        super(TestCheckoutDiff, self).example_branch()
 
116
    def make_example_branch(self):
 
117
        super(TestCheckoutDiff, self).make_example_branch()
107
118
        self.runbzr('checkout . checkout')
108
119
        os.chdir('checkout')
109
120
 
120
131
        self.runbzr('checkout branch2 checkouts/branch2')
121
132
        os.chdir('checkouts')
122
133
 
 
134
 
123
135
class TestDiffLabels(TestDiff):
124
136
 
125
137
    def test_diff_label_removed(self):
126
 
        super(TestDiffLabels, self).example_branch()
 
138
        super(TestDiffLabels, self).make_example_branch()
127
139
        self.runbzr('remove hello')
128
140
        diff = self.run_bzr_captured(['diff'], retcode=1)
129
141
        self.assertTrue("=== removed file 'a/hello'" in diff[0])
130
142
 
131
143
    def test_diff_label_added(self):
132
 
        super(TestDiffLabels, self).example_branch()
 
144
        super(TestDiffLabels, self).make_example_branch()
133
145
        file('barbar', 'wt').write('barbar')
134
146
        self.runbzr('add barbar')
135
147
        diff = self.run_bzr_captured(['diff'], retcode=1)
136
148
        self.assertTrue("=== added file 'b/barbar'" in diff[0])
137
149
 
138
150
    def test_diff_label_modified(self):
139
 
        super(TestDiffLabels, self).example_branch()
 
151
        super(TestDiffLabels, self).make_example_branch()
140
152
        file('hello', 'wt').write('barbar')
141
153
        diff = self.run_bzr_captured(['diff'], retcode=1)
142
154
        self.assertTrue("=== modified file 'a/hello'" in diff[0])
143
155
 
144
156
    def test_diff_label_renamed(self):
145
 
        super(TestDiffLabels, self).example_branch()
 
157
        super(TestDiffLabels, self).make_example_branch()
146
158
        self.runbzr('rename hello gruezi')
147
159
        diff = self.run_bzr_captured(['diff'], retcode=1)
148
160
        self.assertTrue("=== renamed file 'a/hello' => 'b/gruezi'" in diff[0])