/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: Michael Ellerman
  • Date: 2006-05-31 08:44:29 UTC
  • mto: (1711.2.63 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1792.
  • Revision ID: michael@ellerman.id.au-20060531084429-35e5429abda9f560
Add optional location to ancestry and fix behaviour for checkouts.

This adds an optional location parameter to the ancestry command. It also
changes the behaviour of ancestry on checkouts such that if they have
been created with a subset of the branch history, only the subset is
shown by 'bzr ancestry'. Tests for all of that as well.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    def make_example_branch(test):
31
31
        # FIXME: copied from test_too_much -- share elsewhere?
32
32
        test.runbzr('init')
33
 
        file('hello', 'wt').write('foo')
 
33
        file('hello', 'wt').write('foo\n')
34
34
        test.runbzr('add hello')
35
35
        test.runbzr('commit -m setup hello')
36
 
        file('goodbye', 'wt').write('baz')
 
36
        file('goodbye', 'wt').write('baz\n')
37
37
        test.runbzr('add goodbye')
38
38
        test.runbzr('commit -m setup goodbye')
39
39
 
50
50
        os.unlink('moo')
51
51
        self.runbzr('diff')
52
52
 
 
53
    def test_diff_prefix(self):
 
54
        """diff --prefix appends to filenames in output"""
 
55
        self.make_example_branch()
 
56
        file('hello', 'wt').write('hello world!\n')
 
57
        out, err = self.runbzr('diff --prefix old/:new/', retcode=1)
 
58
        self.assertEquals(err, '')
 
59
        self.assertEqualDiff(out, '''\
 
60
=== modified file 'hello'
 
61
--- old/hello\t
 
62
+++ new/hello\t
 
63
@@ -1,1 +1,1 @@
 
64
-foo
 
65
+hello world!
 
66
 
 
67
''')
 
68
 
 
69
    def test_diff_p1(self):
 
70
        """diff -p1 produces lkml-style diffs"""
 
71
        self.make_example_branch()
 
72
        file('hello', 'wt').write('hello world!\n')
 
73
        out, err = self.runbzr('diff -p1', retcode=1)
 
74
        self.assertEquals(err, '')
 
75
        self.assertEqualDiff(out, '''\
 
76
=== modified file 'hello'
 
77
--- old/hello\t
 
78
+++ new/hello\t
 
79
@@ -1,1 +1,1 @@
 
80
-foo
 
81
+hello world!
 
82
 
 
83
''')
 
84
 
 
85
    def test_diff_p0(self):
 
86
        """diff -p0 produces diffs with no prefix"""
 
87
        self.make_example_branch()
 
88
        file('hello', 'wt').write('hello world!\n')
 
89
        out, err = self.runbzr('diff -p0', retcode=1)
 
90
        self.assertEquals(err, '')
 
91
        self.assertEqualDiff(out, '''\
 
92
=== modified file 'hello'
 
93
--- hello\t
 
94
+++ hello\t
 
95
@@ -1,1 +1,1 @@
 
96
-foo
 
97
+hello world!
 
98
 
 
99
''')
 
100
 
53
101
    def test_diff_nonexistent(self):
54
102
        # Get an error from a file that does not exist at all
55
103
        # (Malone #3619)
82
130
        output = self.run_bzr_captured(['diff', '-r', 'branch:branch2', 
83
131
                                        'branch1'],
84
132
                                       retcode=1)
85
 
        self.assertEquals(("=== modified file 'a/file'\n"
86
 
                           "--- a/file\t\n"
87
 
                           "+++ b/file\t\n"
 
133
        self.assertEquals(("=== modified file 'file'\n"
 
134
                           "--- file\t\n"
 
135
                           "+++ file\t\n"
88
136
                           "@@ -1,1 +1,1 @@\n"
89
137
                           "-new content\n"
90
138
                           "+contents of branch1/file\n"
91
139
                           "\n", ''), output)
92
140
        output = self.run_bzr_captured(['diff', 'branch2', 'branch1'],
93
141
                                       retcode=1)
94
 
        self.assertEqualDiff(("=== modified file 'a/file'\n"
95
 
                              "--- a/file\t\n"
96
 
                              "+++ b/file\t\n"
 
142
        self.assertEqualDiff(("=== modified file 'file'\n"
 
143
                              "--- file\t\n"
 
144
                              "+++ file\t\n"
97
145
                              "@@ -1,1 +1,1 @@\n"
98
146
                              "-new content\n"
99
147
                              "+contents of branch1/file\n"
144
192
        super(TestDiffLabels, self).make_example_branch()
145
193
        self.runbzr('remove hello')
146
194
        diff = self.run_bzr_captured(['diff'], retcode=1)
147
 
        self.assertTrue("=== removed file 'a/hello'" in diff[0])
 
195
        self.assertTrue("=== removed file 'hello'" in diff[0])
148
196
 
149
197
    def test_diff_label_added(self):
150
198
        super(TestDiffLabels, self).make_example_branch()
151
199
        file('barbar', 'wt').write('barbar')
152
200
        self.runbzr('add barbar')
153
201
        diff = self.run_bzr_captured(['diff'], retcode=1)
154
 
        self.assertTrue("=== added file 'b/barbar'" in diff[0])
 
202
        self.assertTrue("=== added file 'barbar'" in diff[0])
155
203
 
156
204
    def test_diff_label_modified(self):
157
205
        super(TestDiffLabels, self).make_example_branch()
158
206
        file('hello', 'wt').write('barbar')
159
207
        diff = self.run_bzr_captured(['diff'], retcode=1)
160
 
        self.assertTrue("=== modified file 'a/hello'" in diff[0])
 
208
        self.assertTrue("=== modified file 'hello'" in diff[0])
161
209
 
162
210
    def test_diff_label_renamed(self):
163
211
        super(TestDiffLabels, self).make_example_branch()
164
212
        self.runbzr('rename hello gruezi')
165
213
        diff = self.run_bzr_captured(['diff'], retcode=1)
166
 
        self.assertTrue("=== renamed file 'a/hello' => 'b/gruezi'" in diff[0])
 
214
        self.assertTrue("=== renamed file 'hello' => 'gruezi'" in diff[0])