~ubuntu-branches/ubuntu/lucid/patch/lucid

« back to all changes in this revision

Viewing changes to tests/merge

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2009-12-02 10:25:26 UTC
  • mfrom: (5.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20091202102526-5luk0zsqhghu58l2
Tags: 2.6-2
* Update watch file.
* Section: vcs.
* Suggests: diffutils-doc instead of diff-doc, thanks Christoph Anton
  Mitterer for spotting. Closes: #558974.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2009 Free Software Foundation, Inc.
 
2
#
 
3
# Copying and distribution of this file, with or without modification,
 
4
# in any medium, are permitted without royalty provided the copyright
 
5
# notice and this notice are preserved.
 
6
 
 
7
# Test the --reject-format=FORMAT option
 
8
 
 
9
. $srcdir/test-lib.sh
 
10
 
 
11
require_cat
 
12
require_diff
 
13
use_local_patch
 
14
use_tmpdir
 
15
 
 
16
# ==============================================================
 
17
 
 
18
if ! patch --merge </dev/null 2>/dev/null ; then
 
19
    echo "Merge support DISABLED; skipping this test"
 
20
    exit
 
21
fi
 
22
 
 
23
# ==============================================================
 
24
 
 
25
x() {
 
26
    body=`seq 1 $1`
 
27
    shift
 
28
    echo "$body" > a
 
29
    sed=
 
30
    while test $# -gt 0 -a "$1" != -- ; do
 
31
        sed="$sed -e $1"
 
32
        shift
 
33
    done
 
34
    echo "$body" | sed$sed -e b > b
 
35
    shift
 
36
    sed=
 
37
    while test $# -gt 0 ; do
 
38
        sed="$sed -e $1"
 
39
        shift
 
40
    done
 
41
    echo "$body" | sed$sed -e b > c
 
42
    output=`diff -u a b | patch $ARGS -f --merge c`
 
43
    status=$?
 
44
    echo "$output" | sed -e '/^\(\|patching file c\)$/d'
 
45
    cat c
 
46
    test $status == 0 || echo "Status: $status"
 
47
}
 
48
 
 
49
unset ARGS
 
50
 
 
51
# ==============================================================
 
52
 
 
53
check 'x 3' <<EOF
 
54
1
 
55
2
 
56
3
 
57
EOF
 
58
 
 
59
check 'x 3  2d' <<EOF
 
60
1
 
61
3
 
62
EOF
 
63
 
 
64
check 'x 2  2ib' <<EOF
 
65
1
 
66
b
 
67
2
 
68
EOF
 
69
 
 
70
check 'x 3  2ib -- 3ic' <<EOF
 
71
Hunk #1 merged at 2.
 
72
1
 
73
b
 
74
2
 
75
c
 
76
3
 
77
EOF
 
78
 
 
79
# ==============================================================
 
80
 
 
81
check 'x 3  2c2b -- 2c2c' <<EOF
 
82
Hunk #1 NOT MERGED at 2-6.
 
83
1
 
84
<<<<<<<
 
85
2c
 
86
=======
 
87
2b
 
88
>>>>>>>
 
89
3
 
90
Status: 1
 
91
EOF
 
92
 
 
93
check 'x 3  2d -- 2d' <<EOF
 
94
Hunk #1 already applied at 2.
 
95
1
 
96
3
 
97
EOF
 
98
 
 
99
check 'x 2  2ibc -- 2ibc' <<EOF
 
100
Hunk #1 already applied at 2.
 
101
1
 
102
bc
 
103
2
 
104
EOF
 
105
 
 
106
check 'x 4  2aa 2aa -- 2aa 2aa' <<EOF
 
107
Hunk #1 already applied at 3-4.
 
108
1
 
109
2
 
110
a
 
111
a
 
112
3
 
113
4
 
114
EOF
 
115
 
 
116
# ==============================================================
 
117
 
 
118
check 'x 4  2d -- 3d' <<EOF
 
119
Hunk #1 NOT MERGED at 2-6.
 
120
1
 
121
<<<<<<<
 
122
2
 
123
=======
 
124
3
 
125
>>>>>>>
 
126
4
 
127
Status: 1
 
128
EOF
 
129
 
 
130
check 'x 4  3d -- 2d' <<EOF
 
131
Hunk #1 NOT MERGED at 2-6.
 
132
1
 
133
<<<<<<<
 
134
3
 
135
=======
 
136
2
 
137
>>>>>>>
 
138
4
 
139
Status: 1
 
140
EOF
 
141
 
 
142
# ==============================================================
 
143
 
 
144
check 'x 3  3ib -- 2d' <<EOF
 
145
Hunk #1 NOT MERGED at 2-6.
 
146
1
 
147
<<<<<<<
 
148
=======
 
149
2
 
150
b
 
151
>>>>>>>
 
152
3
 
153
Status: 1
 
154
EOF
 
155
 
 
156
check 'x 3  2d -- 3ib' <<EOF
 
157
Hunk #1 NOT MERGED at 2-6.
 
158
1
 
159
<<<<<<<
 
160
2
 
161
b
 
162
=======
 
163
>>>>>>>
 
164
3
 
165
Status: 1
 
166
EOF
 
167
 
 
168
# ==============================================================
 
169
 
 
170
check 'x 1  1cb -- 1cc' <<EOF
 
171
Hunk #1 NOT MERGED at 1-4.
 
172
<<<<<<<
 
173
=======
 
174
b
 
175
>>>>>>>
 
176
c
 
177
Status: 1
 
178
EOF
 
179
 
 
180
check 'x 4  2ca 3cb -- 2ca 3cc' <<EOF
 
181
Hunk #1 NOT MERGED at 3-7.
 
182
1
 
183
a
 
184
<<<<<<<
 
185
c
 
186
=======
 
187
b
 
188
>>>>>>>
 
189
4
 
190
Status: 1
 
191
EOF
 
192
 
 
193
check 'x 6  3c3b 4c4b -- 3c3c 4c4c' <<EOF
 
194
Hunk #1 NOT MERGED at 3-9.
 
195
1
 
196
2
 
197
<<<<<<<
 
198
3c
 
199
4c
 
200
=======
 
201
3b
 
202
4b
 
203
>>>>>>>
 
204
5
 
205
6
 
206
Status: 1
 
207
EOF
 
208
 
 
209
check 'x 4  2cb 3ca -- 2cc 3ca' <<EOF
 
210
Hunk #1 NOT MERGED at 2-6.
 
211
1
 
212
<<<<<<<
 
213
c
 
214
=======
 
215
b
 
216
>>>>>>>
 
217
a
 
218
4
 
219
Status: 1
 
220
EOF
 
221
 
 
222
check 'x 3  2ib 3ib -- 2ic' <<EOF
 
223
Hunk #1 NOT MERGED at 2-6, merged at 8.
 
224
1
 
225
<<<<<<<
 
226
c
 
227
=======
 
228
b
 
229
>>>>>>>
 
230
2
 
231
b
 
232
3
 
233
Status: 1
 
234
EOF
 
235
 
 
236
check 'x 3  2ib 3ib 3ib -- 2ic' <<EOF
 
237
Hunk #1 NOT MERGED at 2-6, merged at 8-9.
 
238
1
 
239
<<<<<<<
 
240
c
 
241
=======
 
242
b
 
243
>>>>>>>
 
244
2
 
245
b
 
246
b
 
247
3
 
248
Status: 1
 
249
EOF
 
250
 
 
251
check 'x 9  4ca 5cb 6ca -- 4ca 5cc 6ca' <<EOF
 
252
Hunk #1 NOT MERGED at 5-9.
 
253
1
 
254
2
 
255
3
 
256
a
 
257
<<<<<<<
 
258
c
 
259
=======
 
260
b
 
261
>>>>>>>
 
262
a
 
263
7
 
264
8
 
265
9
 
266
Status: 1
 
267
EOF
 
268
 
 
269
check 'x 3  2ib 3ib -- 1i0' <<EOF
 
270
0
 
271
1
 
272
b
 
273
2
 
274
b
 
275
3
 
276
EOF
 
277
 
 
278
check 'x 4  2ib 4ib -- 1i0 3ic' <<EOF
 
279
Hunk #1 merged at 3,7.
 
280
0
 
281
1
 
282
b
 
283
2
 
284
c
 
285
3
 
286
b
 
287
4
 
288
EOF
 
289
 
 
290
# ==============================================================
 
291
 
 
292
check 'x 5  2,4d -- 3c3c' <<EOF
 
293
Hunk #1 NOT MERGED at 2-7.
 
294
1
 
295
<<<<<<<
 
296
2
 
297
3c
 
298
4
 
299
=======
 
300
>>>>>>>
 
301
5
 
302
Status: 1
 
303
EOF
 
304
 
 
305
check 'x 5  3c3c -- 2,4d' <<EOF
 
306
Hunk #1 NOT MERGED at 2-7.
 
307
1
 
308
<<<<<<<
 
309
=======
 
310
2
 
311
3c
 
312
4
 
313
>>>>>>>
 
314
5
 
315
Status: 1
 
316
EOF
 
317
 
 
318
# ==============================================================
 
319
 
 
320
check 'x 3  1,2d -- 2ic' <<EOF
 
321
Hunk #1 NOT MERGED at 1-6.
 
322
<<<<<<<
 
323
1
 
324
c
 
325
2
 
326
=======
 
327
>>>>>>>
 
328
3
 
329
Status: 1
 
330
EOF
 
331
 
 
332
check 'x 3  2ic -- 1,2d' <<EOF
 
333
Hunk #1 NOT MERGED at 1-6.
 
334
<<<<<<<
 
335
=======
 
336
1
 
337
c
 
338
2
 
339
>>>>>>>
 
340
3
 
341
Status: 1
 
342
EOF