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