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