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