##// END OF EJS Templates
tests: add test-commit-interactive-curses.t "require tic" for test portability...
FUJIWARA Katsunori -
r30236:141cb12c stable
parent child Browse files
Show More
@@ -1,405 +1,407 b''
1 #require tic
2
1 Set up a repo
3 Set up a repo
2
4
3 $ cp $HGRCPATH $HGRCPATH.pretest
5 $ cp $HGRCPATH $HGRCPATH.pretest
4 $ cat <<EOF >> $HGRCPATH
6 $ cat <<EOF >> $HGRCPATH
5 > [ui]
7 > [ui]
6 > interactive = true
8 > interactive = true
7 > interface = curses
9 > interface = curses
8 > [experimental]
10 > [experimental]
9 > crecordtest = testModeCommands
11 > crecordtest = testModeCommands
10 > EOF
12 > EOF
11
13
12 Record with noeol at eof (issue5268)
14 Record with noeol at eof (issue5268)
13 $ hg init noeol
15 $ hg init noeol
14 $ cd noeol
16 $ cd noeol
15 $ printf '0' > a
17 $ printf '0' > a
16 $ printf '0\n' > b
18 $ printf '0\n' > b
17 $ hg ci -Aqm initial
19 $ hg ci -Aqm initial
18 $ printf '1\n0' > a
20 $ printf '1\n0' > a
19 $ printf '1\n0\n' > b
21 $ printf '1\n0\n' > b
20 $ cat <<EOF >testModeCommands
22 $ cat <<EOF >testModeCommands
21 > c
23 > c
22 > EOF
24 > EOF
23 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -m "add hunks" -d "0 0"
25 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -m "add hunks" -d "0 0"
24 $ cd ..
26 $ cd ..
25
27
26 Normal repo
28 Normal repo
27 $ hg init a
29 $ hg init a
28 $ cd a
30 $ cd a
29
31
30 Committing some changes but stopping on the way
32 Committing some changes but stopping on the way
31
33
32 $ echo "a" > a
34 $ echo "a" > a
33 $ hg add a
35 $ hg add a
34 $ cat <<EOF >testModeCommands
36 $ cat <<EOF >testModeCommands
35 > TOGGLE
37 > TOGGLE
36 > X
38 > X
37 > EOF
39 > EOF
38 $ hg commit -i -m "a" -d "0 0"
40 $ hg commit -i -m "a" -d "0 0"
39 no changes to record
41 no changes to record
40 [1]
42 [1]
41 $ hg tip
43 $ hg tip
42 changeset: -1:000000000000
44 changeset: -1:000000000000
43 tag: tip
45 tag: tip
44 user:
46 user:
45 date: Thu Jan 01 00:00:00 1970 +0000
47 date: Thu Jan 01 00:00:00 1970 +0000
46
48
47
49
48 Committing some changes
50 Committing some changes
49
51
50 $ cat <<EOF >testModeCommands
52 $ cat <<EOF >testModeCommands
51 > X
53 > X
52 > EOF
54 > EOF
53 $ hg commit -i -m "a" -d "0 0"
55 $ hg commit -i -m "a" -d "0 0"
54 $ hg tip
56 $ hg tip
55 changeset: 0:cb9a9f314b8b
57 changeset: 0:cb9a9f314b8b
56 tag: tip
58 tag: tip
57 user: test
59 user: test
58 date: Thu Jan 01 00:00:00 1970 +0000
60 date: Thu Jan 01 00:00:00 1970 +0000
59 summary: a
61 summary: a
60
62
61 Check that commit -i works with no changes
63 Check that commit -i works with no changes
62 $ hg commit -i
64 $ hg commit -i
63 no changes to record
65 no changes to record
64 [1]
66 [1]
65
67
66 Committing only one file
68 Committing only one file
67
69
68 $ echo "a" >> a
70 $ echo "a" >> a
69 >>> open('b', 'wb').write("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n")
71 >>> open('b', 'wb').write("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n")
70 $ hg add b
72 $ hg add b
71 $ cat <<EOF >testModeCommands
73 $ cat <<EOF >testModeCommands
72 > TOGGLE
74 > TOGGLE
73 > KEY_DOWN
75 > KEY_DOWN
74 > X
76 > X
75 > EOF
77 > EOF
76 $ hg commit -i -m "one file" -d "0 0"
78 $ hg commit -i -m "one file" -d "0 0"
77 $ hg tip
79 $ hg tip
78 changeset: 1:fb2705a663ea
80 changeset: 1:fb2705a663ea
79 tag: tip
81 tag: tip
80 user: test
82 user: test
81 date: Thu Jan 01 00:00:00 1970 +0000
83 date: Thu Jan 01 00:00:00 1970 +0000
82 summary: one file
84 summary: one file
83
85
84 $ hg cat -r tip a
86 $ hg cat -r tip a
85 a
87 a
86 $ cat a
88 $ cat a
87 a
89 a
88 a
90 a
89
91
90 Committing only one hunk while aborting edition of hunk
92 Committing only one hunk while aborting edition of hunk
91
93
92 - Untoggle all the hunks, go down to the second file
94 - Untoggle all the hunks, go down to the second file
93 - unfold it
95 - unfold it
94 - go down to second hunk (1 for the first hunk, 1 for the first hunkline, 1 for the second hunk, 1 for the second hunklike)
96 - go down to second hunk (1 for the first hunk, 1 for the first hunkline, 1 for the second hunk, 1 for the second hunklike)
95 - toggle the second hunk
97 - toggle the second hunk
96 - toggle on and off the amend mode (to check that it toggles off)
98 - toggle on and off the amend mode (to check that it toggles off)
97 - edit the hunk and quit the editor immediately with non-zero status
99 - edit the hunk and quit the editor immediately with non-zero status
98 - commit
100 - commit
99
101
100 $ printf "printf 'editor ran\n'; exit 1" > editor.sh
102 $ printf "printf 'editor ran\n'; exit 1" > editor.sh
101 $ echo "x" > c
103 $ echo "x" > c
102 $ cat b >> c
104 $ cat b >> c
103 $ echo "y" >> c
105 $ echo "y" >> c
104 $ mv c b
106 $ mv c b
105 $ cat <<EOF >testModeCommands
107 $ cat <<EOF >testModeCommands
106 > A
108 > A
107 > KEY_DOWN
109 > KEY_DOWN
108 > f
110 > f
109 > KEY_DOWN
111 > KEY_DOWN
110 > KEY_DOWN
112 > KEY_DOWN
111 > KEY_DOWN
113 > KEY_DOWN
112 > KEY_DOWN
114 > KEY_DOWN
113 > TOGGLE
115 > TOGGLE
114 > a
116 > a
115 > a
117 > a
116 > e
118 > e
117 > X
119 > X
118 > EOF
120 > EOF
119 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -m "one hunk" -d "0 0"
121 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -m "one hunk" -d "0 0"
120 editor ran
122 editor ran
121 $ rm editor.sh
123 $ rm editor.sh
122 $ hg tip
124 $ hg tip
123 changeset: 2:7d10dfe755a8
125 changeset: 2:7d10dfe755a8
124 tag: tip
126 tag: tip
125 user: test
127 user: test
126 date: Thu Jan 01 00:00:00 1970 +0000
128 date: Thu Jan 01 00:00:00 1970 +0000
127 summary: one hunk
129 summary: one hunk
128
130
129 $ hg cat -r tip b
131 $ hg cat -r tip b
130 1
132 1
131 2
133 2
132 3
134 3
133 4
135 4
134 5
136 5
135 6
137 6
136 7
138 7
137 8
139 8
138 9
140 9
139 10
141 10
140 y
142 y
141 $ cat b
143 $ cat b
142 x
144 x
143 1
145 1
144 2
146 2
145 3
147 3
146 4
148 4
147 5
149 5
148 6
150 6
149 7
151 7
150 8
152 8
151 9
153 9
152 10
154 10
153 y
155 y
154 $ hg commit -m "other hunks"
156 $ hg commit -m "other hunks"
155 $ hg tip
157 $ hg tip
156 changeset: 3:a6735021574d
158 changeset: 3:a6735021574d
157 tag: tip
159 tag: tip
158 user: test
160 user: test
159 date: Thu Jan 01 00:00:00 1970 +0000
161 date: Thu Jan 01 00:00:00 1970 +0000
160 summary: other hunks
162 summary: other hunks
161
163
162 $ hg cat -r tip b
164 $ hg cat -r tip b
163 x
165 x
164 1
166 1
165 2
167 2
166 3
168 3
167 4
169 4
168 5
170 5
169 6
171 6
170 7
172 7
171 8
173 8
172 9
174 9
173 10
175 10
174 y
176 y
175
177
176 Newly added files can be selected with the curses interface
178 Newly added files can be selected with the curses interface
177
179
178 $ hg update -C .
180 $ hg update -C .
179 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
181 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
180 $ echo "hello" > x
182 $ echo "hello" > x
181 $ hg add x
183 $ hg add x
182 $ cat <<EOF >testModeCommands
184 $ cat <<EOF >testModeCommands
183 > TOGGLE
185 > TOGGLE
184 > TOGGLE
186 > TOGGLE
185 > X
187 > X
186 > EOF
188 > EOF
187 $ hg st
189 $ hg st
188 A x
190 A x
189 ? testModeCommands
191 ? testModeCommands
190 $ hg commit -i -m "newly added file" -d "0 0"
192 $ hg commit -i -m "newly added file" -d "0 0"
191 $ hg st
193 $ hg st
192 ? testModeCommands
194 ? testModeCommands
193
195
194 Amend option works
196 Amend option works
195 $ echo "hello world" > x
197 $ echo "hello world" > x
196 $ hg diff -c .
198 $ hg diff -c .
197 diff -r a6735021574d -r 2b0e9be4d336 x
199 diff -r a6735021574d -r 2b0e9be4d336 x
198 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
200 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
199 +++ b/x Thu Jan 01 00:00:00 1970 +0000
201 +++ b/x Thu Jan 01 00:00:00 1970 +0000
200 @@ -0,0 +1,1 @@
202 @@ -0,0 +1,1 @@
201 +hello
203 +hello
202 $ cat <<EOF >testModeCommands
204 $ cat <<EOF >testModeCommands
203 > a
205 > a
204 > X
206 > X
205 > EOF
207 > EOF
206 $ hg commit -i -m "newly added file" -d "0 0"
208 $ hg commit -i -m "newly added file" -d "0 0"
207 saved backup bundle to $TESTTMP/a/.hg/strip-backup/2b0e9be4d336-28bbe4e2-amend-backup.hg (glob)
209 saved backup bundle to $TESTTMP/a/.hg/strip-backup/2b0e9be4d336-28bbe4e2-amend-backup.hg (glob)
208 $ hg diff -c .
210 $ hg diff -c .
209 diff -r a6735021574d -r c1d239d165ae x
211 diff -r a6735021574d -r c1d239d165ae x
210 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
212 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
211 +++ b/x Thu Jan 01 00:00:00 1970 +0000
213 +++ b/x Thu Jan 01 00:00:00 1970 +0000
212 @@ -0,0 +1,1 @@
214 @@ -0,0 +1,1 @@
213 +hello world
215 +hello world
214
216
215 Editing a hunk puts you back on that hunk when done editing (issue5041)
217 Editing a hunk puts you back on that hunk when done editing (issue5041)
216 To do that, we change two lines in a file, pretend to edit the second line,
218 To do that, we change two lines in a file, pretend to edit the second line,
217 exit, toggle the line selected at the end of the edit and commit.
219 exit, toggle the line selected at the end of the edit and commit.
218 The first line should be recorded if we were put on the second line at the end
220 The first line should be recorded if we were put on the second line at the end
219 of the edit.
221 of the edit.
220
222
221 $ hg update -C .
223 $ hg update -C .
222 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
224 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
223 $ echo "foo" > x
225 $ echo "foo" > x
224 $ echo "hello world" >> x
226 $ echo "hello world" >> x
225 $ echo "bar" >> x
227 $ echo "bar" >> x
226 $ cat <<EOF >testModeCommands
228 $ cat <<EOF >testModeCommands
227 > f
229 > f
228 > KEY_DOWN
230 > KEY_DOWN
229 > KEY_DOWN
231 > KEY_DOWN
230 > KEY_DOWN
232 > KEY_DOWN
231 > KEY_DOWN
233 > KEY_DOWN
232 > e
234 > e
233 > TOGGLE
235 > TOGGLE
234 > X
236 > X
235 > EOF
237 > EOF
236 $ printf "printf 'editor ran\n'; exit 0" > editor.sh
238 $ printf "printf 'editor ran\n'; exit 0" > editor.sh
237 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -m "edit hunk" -d "0 0"
239 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -m "edit hunk" -d "0 0"
238 editor ran
240 editor ran
239 $ hg cat -r . x
241 $ hg cat -r . x
240 foo
242 foo
241 hello world
243 hello world
242
244
243 Testing the review option. The entire final filtered patch should show
245 Testing the review option. The entire final filtered patch should show
244 up in the editor and be editable. We will unselect the second file and
246 up in the editor and be editable. We will unselect the second file and
245 the first hunk of the third file. During review, we will decide that
247 the first hunk of the third file. During review, we will decide that
246 "lower" sounds better than "bottom", and the final commit should
248 "lower" sounds better than "bottom", and the final commit should
247 reflect this edition.
249 reflect this edition.
248
250
249 $ hg update -C .
251 $ hg update -C .
250 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
252 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
251 $ echo "top" > c
253 $ echo "top" > c
252 $ cat x >> c
254 $ cat x >> c
253 $ echo "bottom" >> c
255 $ echo "bottom" >> c
254 $ mv c x
256 $ mv c x
255 $ echo "third a" >> a
257 $ echo "third a" >> a
256 $ echo "we will unselect this" >> b
258 $ echo "we will unselect this" >> b
257
259
258 $ cat > editor.sh <<EOF
260 $ cat > editor.sh <<EOF
259 > cat "\$1"
261 > cat "\$1"
260 > cat "\$1" | sed s/bottom/lower/ > tmp
262 > cat "\$1" | sed s/bottom/lower/ > tmp
261 > mv tmp "\$1"
263 > mv tmp "\$1"
262 > EOF
264 > EOF
263 $ cat > testModeCommands <<EOF
265 $ cat > testModeCommands <<EOF
264 > KEY_DOWN
266 > KEY_DOWN
265 > TOGGLE
267 > TOGGLE
266 > KEY_DOWN
268 > KEY_DOWN
267 > f
269 > f
268 > KEY_DOWN
270 > KEY_DOWN
269 > TOGGLE
271 > TOGGLE
270 > R
272 > R
271 > EOF
273 > EOF
272
274
273 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -m "review hunks" -d "0 0"
275 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit -i -m "review hunks" -d "0 0"
274 # To remove '-' lines, make them ' ' lines (context).
276 # To remove '-' lines, make them ' ' lines (context).
275 # To remove '+' lines, delete them.
277 # To remove '+' lines, delete them.
276 # Lines starting with # will be removed from the patch.
278 # Lines starting with # will be removed from the patch.
277 #
279 #
278 # If the patch applies cleanly, the edited patch will immediately
280 # If the patch applies cleanly, the edited patch will immediately
279 # be finalised. If it does not apply cleanly, rejects files will be
281 # be finalised. If it does not apply cleanly, rejects files will be
280 # generated. You can use those when you try again.
282 # generated. You can use those when you try again.
281 diff --git a/a b/a
283 diff --git a/a b/a
282 --- a/a
284 --- a/a
283 +++ b/a
285 +++ b/a
284 @@ -1,2 +1,3 @@
286 @@ -1,2 +1,3 @@
285 a
287 a
286 a
288 a
287 +third a
289 +third a
288 diff --git a/x b/x
290 diff --git a/x b/x
289 --- a/x
291 --- a/x
290 +++ b/x
292 +++ b/x
291 @@ -1,2 +1,3 @@
293 @@ -1,2 +1,3 @@
292 foo
294 foo
293 hello world
295 hello world
294 +bottom
296 +bottom
295
297
296 $ hg cat -r . a
298 $ hg cat -r . a
297 a
299 a
298 a
300 a
299 third a
301 third a
300
302
301 $ hg cat -r . b
303 $ hg cat -r . b
302 x
304 x
303 1
305 1
304 2
306 2
305 3
307 3
306 4
308 4
307 5
309 5
308 6
310 6
309 7
311 7
310 8
312 8
311 9
313 9
312 10
314 10
313 y
315 y
314
316
315 $ hg cat -r . x
317 $ hg cat -r . x
316 foo
318 foo
317 hello world
319 hello world
318 lower
320 lower
319 Check ui.interface logic for the chunkselector
321 Check ui.interface logic for the chunkselector
320
322
321 The default interface is text
323 The default interface is text
322 $ cp $HGRCPATH.pretest $HGRCPATH
324 $ cp $HGRCPATH.pretest $HGRCPATH
323 $ chunkselectorinterface() {
325 $ chunkselectorinterface() {
324 > python <<EOF
326 > python <<EOF
325 > from mercurial import hg, ui, parsers;\
327 > from mercurial import hg, ui, parsers;\
326 > repo = hg.repository(ui.ui(), ".");\
328 > repo = hg.repository(ui.ui(), ".");\
327 > print repo.ui.interface("chunkselector")
329 > print repo.ui.interface("chunkselector")
328 > EOF
330 > EOF
329 > }
331 > }
330 $ chunkselectorinterface
332 $ chunkselectorinterface
331 text
333 text
332
334
333 If only the default is set, we'll use that for the feature, too
335 If only the default is set, we'll use that for the feature, too
334 $ cp $HGRCPATH.pretest $HGRCPATH
336 $ cp $HGRCPATH.pretest $HGRCPATH
335 $ cat <<EOF >> $HGRCPATH
337 $ cat <<EOF >> $HGRCPATH
336 > [ui]
338 > [ui]
337 > interface = curses
339 > interface = curses
338 > EOF
340 > EOF
339 $ chunkselectorinterface
341 $ chunkselectorinterface
340 curses
342 curses
341
343
342 It is possible to override the default interface with a feature specific
344 It is possible to override the default interface with a feature specific
343 interface
345 interface
344 $ cp $HGRCPATH.pretest $HGRCPATH
346 $ cp $HGRCPATH.pretest $HGRCPATH
345 $ cat <<EOF >> $HGRCPATH
347 $ cat <<EOF >> $HGRCPATH
346 > [ui]
348 > [ui]
347 > interface = text
349 > interface = text
348 > interface.chunkselector = curses
350 > interface.chunkselector = curses
349 > EOF
351 > EOF
350
352
351 $ chunkselectorinterface
353 $ chunkselectorinterface
352 curses
354 curses
353
355
354 $ cp $HGRCPATH.pretest $HGRCPATH
356 $ cp $HGRCPATH.pretest $HGRCPATH
355 $ cat <<EOF >> $HGRCPATH
357 $ cat <<EOF >> $HGRCPATH
356 > [ui]
358 > [ui]
357 > interface = curses
359 > interface = curses
358 > interface.chunkselector = text
360 > interface.chunkselector = text
359 > EOF
361 > EOF
360
362
361 $ chunkselectorinterface
363 $ chunkselectorinterface
362 text
364 text
363
365
364 If a bad interface name is given, we use the default value (with a nice
366 If a bad interface name is given, we use the default value (with a nice
365 error message to suggest that the configuration needs to be fixed)
367 error message to suggest that the configuration needs to be fixed)
366
368
367 $ cp $HGRCPATH.pretest $HGRCPATH
369 $ cp $HGRCPATH.pretest $HGRCPATH
368 $ cat <<EOF >> $HGRCPATH
370 $ cat <<EOF >> $HGRCPATH
369 > [ui]
371 > [ui]
370 > interface = blah
372 > interface = blah
371 > EOF
373 > EOF
372 $ chunkselectorinterface
374 $ chunkselectorinterface
373 invalid value for ui.interface: blah (using text)
375 invalid value for ui.interface: blah (using text)
374 text
376 text
375
377
376 $ cp $HGRCPATH.pretest $HGRCPATH
378 $ cp $HGRCPATH.pretest $HGRCPATH
377 $ cat <<EOF >> $HGRCPATH
379 $ cat <<EOF >> $HGRCPATH
378 > [ui]
380 > [ui]
379 > interface = curses
381 > interface = curses
380 > interface.chunkselector = blah
382 > interface.chunkselector = blah
381 > EOF
383 > EOF
382 $ chunkselectorinterface
384 $ chunkselectorinterface
383 invalid value for ui.interface.chunkselector: blah (using curses)
385 invalid value for ui.interface.chunkselector: blah (using curses)
384 curses
386 curses
385
387
386 $ cp $HGRCPATH.pretest $HGRCPATH
388 $ cp $HGRCPATH.pretest $HGRCPATH
387 $ cat <<EOF >> $HGRCPATH
389 $ cat <<EOF >> $HGRCPATH
388 > [ui]
390 > [ui]
389 > interface = blah
391 > interface = blah
390 > interface.chunkselector = curses
392 > interface.chunkselector = curses
391 > EOF
393 > EOF
392 $ chunkselectorinterface
394 $ chunkselectorinterface
393 invalid value for ui.interface: blah
395 invalid value for ui.interface: blah
394 curses
396 curses
395
397
396 $ cp $HGRCPATH.pretest $HGRCPATH
398 $ cp $HGRCPATH.pretest $HGRCPATH
397 $ cat <<EOF >> $HGRCPATH
399 $ cat <<EOF >> $HGRCPATH
398 > [ui]
400 > [ui]
399 > interface = blah
401 > interface = blah
400 > interface.chunkselector = blah
402 > interface.chunkselector = blah
401 > EOF
403 > EOF
402 $ chunkselectorinterface
404 $ chunkselectorinterface
403 invalid value for ui.interface: blah
405 invalid value for ui.interface: blah
404 invalid value for ui.interface.chunkselector: blah (using text)
406 invalid value for ui.interface.chunkselector: blah (using text)
405 text
407 text
General Comments 0
You need to be logged in to leave comments. Login now