/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2006-03-03 02:09:49 UTC
  • mto: (1594.2.4 integration)
  • mto: This revision was merged to the branch mainline in revision 1596.
  • Revision ID: robertc@robertcollins.net-20060303020949-0ddc6f33d0a43943
Smoke test for RevisionStore factories creating revision stores.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 by Canonical Ltd
 
1
# Copyright (C) 2005 by Canonical Ltd
 
2
# -*- coding: utf-8 -*-
2
3
 
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
26
27
 
27
28
 
28
29
class TestDiff(ExternalBase):
29
 
 
30
 
    def make_example_branch(test):
 
30
    def 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.make_example_branch()
 
41
        self.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
 
 
70
53
    def example_branches(self):
71
54
        self.build_tree(['branch1/', 'branch1/file'], line_endings='binary')
72
55
        self.capture('init branch1')
82
65
        output = self.run_bzr_captured(['diff', '-r', 'branch:branch2', 
83
66
                                        'branch1'],
84
67
                                       retcode=1)
85
 
        self.assertEquals(("=== modified file 'a/file'\n"
86
 
                           "--- a/file\t\n"
87
 
                           "+++ b/file\t\n"
 
68
        self.assertEquals(("=== modified file 'file'\n"
 
69
                           "--- file\t\n"
 
70
                           "+++ file\t\n"
88
71
                           "@@ -1,1 +1,1 @@\n"
89
72
                           "-new content\n"
90
73
                           "+contents of branch1/file\n"
91
74
                           "\n", ''), output)
92
75
        output = self.run_bzr_captured(['diff', 'branch2', 'branch1'],
93
76
                                       retcode=1)
94
 
        self.assertEqualDiff(("=== modified file 'a/file'\n"
95
 
                              "--- a/file\t\n"
96
 
                              "+++ b/file\t\n"
 
77
        self.assertEqualDiff(("=== modified file 'file'\n"
 
78
                              "--- file\t\n"
 
79
                              "+++ file\t\n"
97
80
                              "@@ -1,1 +1,1 @@\n"
98
81
                              "-new content\n"
99
82
                              "+contents of branch1/file\n"
119
102
 
120
103
class TestCheckoutDiff(TestDiff):
121
104
 
122
 
    def make_example_branch(self):
123
 
        super(TestCheckoutDiff, self).make_example_branch()
 
105
    def example_branch(self):
 
106
        super(TestCheckoutDiff, self).example_branch()
124
107
        self.runbzr('checkout . checkout')
125
108
        os.chdir('checkout')
126
109
 
136
119
        self.runbzr('checkout branch1 checkouts/branch1')
137
120
        self.runbzr('checkout branch2 checkouts/branch2')
138
121
        os.chdir('checkouts')
139
 
 
140
 
 
141
 
class TestDiffLabels(TestDiff):
142
 
 
143
 
    def test_diff_label_removed(self):
144
 
        super(TestDiffLabels, self).make_example_branch()
145
 
        self.runbzr('remove hello')
146
 
        diff = self.run_bzr_captured(['diff'], retcode=1)
147
 
        self.assertTrue("=== removed file 'a/hello'" in diff[0])
148
 
 
149
 
    def test_diff_label_added(self):
150
 
        super(TestDiffLabels, self).make_example_branch()
151
 
        file('barbar', 'wt').write('barbar')
152
 
        self.runbzr('add barbar')
153
 
        diff = self.run_bzr_captured(['diff'], retcode=1)
154
 
        self.assertTrue("=== added file 'b/barbar'" in diff[0])
155
 
 
156
 
    def test_diff_label_modified(self):
157
 
        super(TestDiffLabels, self).make_example_branch()
158
 
        file('hello', 'wt').write('barbar')
159
 
        diff = self.run_bzr_captured(['diff'], retcode=1)
160
 
        self.assertTrue("=== modified file 'a/hello'" in diff[0])
161
 
 
162
 
    def test_diff_label_renamed(self):
163
 
        super(TestDiffLabels, self).make_example_branch()
164
 
        self.runbzr('rename hello gruezi')
165
 
        diff = self.run_bzr_captured(['diff'], retcode=1)
166
 
        self.assertTrue("=== renamed file 'a/hello' => 'b/gruezi'" in diff[0])