comparison tests/test-keyword.t @ 16324:46b991a1f428

record: allow splitting of hunks by manually editing patches It is possible that unrelated changes in a file are on sequential lines. The current record extension does not allow these to be committed independently. An example use case for this is in software development for deeply embedded real-time systems. In these environments, it is not always possible to use a debugger (due to time-constraints) and hence inline UART-based printing is often used. When fixing a bug in a module, it is often convenient to add a large number of 'printf's (linked to the UART via a custom fputc) to the module in order to work out what is going wrong. printf is a very slow function (and also variadic so somewhat frowned upon by the MISRA standard) and hence it is highly undesirable to commit these lines to the repository. If only a partial fix is implemented, however, it is desirable to commit the fix without deleting all of the printf lines. This is also simplifies removal of the printf lines as once the final fix is committed, 'hg revert' does the rest. It is likely that the printf lines will be very near the actual fix, so being able to split the hunk is very useful in this case. There were two alternatives I considered for the user interface. One was to manually edit the patch, the other to allow a hunk to be split into individual lines for consideration. The latter option would require a significant refactor of the record module and is less flexible. While the former is potentially more complicated to use, this is a feature that is likely to only be used in certain exceptional cases (such as the use case proposed above) and hence I felt that the complexity would not be a considerable issue. I've also written a follow-up patch that refactors the 'prompt' code to base everything on the choices variable. This tidies up and clarifies the code a bit (removes constructs like 'if ret == 7' and removes the 'e' option from the file scope options as it's not relevant there. It's not really a necessity, so I've excluded it from this submission for now, but I can send it separately if there's a desire and it's on bitbucket (see below) in the meantime. Possible future improvements include: * Tidying up the 'prompt' code to base everything on the choices variable. This would allow entries to be removed from the prompt as currently 'e' is offered even for entire file patches, which is currently unsupported. * Allowing the entire file (or even multi-file) patch to be edited manually: this would require quite a large refactor without much benefit, so I decided to exclude it from the initial submission. * Allow the option to retry if a patch fails to apply (this is what Git does). This would require quite a bit of refactoring given the current 'hg record' implementation, so it's debatable whether it's worth it. Output is similar to existing record user interface except that an additional option ('e') exists to allow manual editing of the patch. This opens the user's configured editor with the patch. A comment is added to the bottom of the patch explaining what to do (based on Git's one). A large proportion of the changeset is test-case changes to update the options reported by record (Ynesfdaq? instead of Ynsfdaq?). Functional changes are in record.py and there are some new test cases in test-record.t.
author A. S. Budden <abudden@gmail.com>
date Fri, 30 Mar 2012 22:08:46 +0100
parents 20ad8f0512a2
children d6a4cfefafb3
comparison
equal deleted inserted replaced
16318:73f4e05287b4 16324:46b991a1f428
336 > y 336 > y
337 > n 337 > n
338 > EOF 338 > EOF
339 diff --git a/a b/a 339 diff --git a/a b/a
340 2 hunks, 2 lines changed 340 2 hunks, 2 lines changed
341 examine changes to 'a'? [Ynsfdaq?] 341 examine changes to 'a'? [Ynesfdaq?]
342 @@ -1,3 +1,4 @@ 342 @@ -1,3 +1,4 @@
343 expand $Id$ 343 expand $Id$
344 +foo 344 +foo
345 do not process $Id: 345 do not process $Id:
346 xxx $ 346 xxx $
347 record change 1/2 to 'a'? [Ynsfdaq?] 347 record change 1/2 to 'a'? [Ynesfdaq?]
348 @@ -2,2 +3,3 @@ 348 @@ -2,2 +3,3 @@
349 do not process $Id: 349 do not process $Id:
350 xxx $ 350 xxx $
351 +bar 351 +bar
352 record change 2/2 to 'a'? [Ynsfdaq?] 352 record change 2/2 to 'a'? [Ynesfdaq?]
353 353
354 $ hg identify 354 $ hg identify
355 d17e03c92c97+ tip 355 d17e03c92c97+ tip
356 $ hg status 356 $ hg status
357 M a 357 M a
393 > y 393 > y
394 > y 394 > y
395 > EOF 395 > EOF
396 diff --git a/a b/a 396 diff --git a/a b/a
397 2 hunks, 2 lines changed 397 2 hunks, 2 lines changed
398 examine changes to 'a'? [Ynsfdaq?] 398 examine changes to 'a'? [Ynesfdaq?]
399 @@ -1,3 +1,4 @@ 399 @@ -1,3 +1,4 @@
400 expand $Id$ 400 expand $Id$
401 +foo 401 +foo
402 do not process $Id: 402 do not process $Id:
403 xxx $ 403 xxx $
404 record change 1/2 to 'a'? [Ynsfdaq?] 404 record change 1/2 to 'a'? [Ynesfdaq?]
405 @@ -2,2 +3,3 @@ 405 @@ -2,2 +3,3 @@
406 do not process $Id: 406 do not process $Id:
407 xxx $ 407 xxx $
408 +bar 408 +bar
409 record change 2/2 to 'a'? [Ynsfdaq?] 409 record change 2/2 to 'a'? [Ynesfdaq?]
410 410
411 File a should be clean 411 File a should be clean
412 412
413 $ hg status -A a 413 $ hg status -A a
414 C a 414 C a
460 $ hg -v record -l msg -d '1 12' r<<EOF 460 $ hg -v record -l msg -d '1 12' r<<EOF
461 > y 461 > y
462 > EOF 462 > EOF
463 diff --git a/r b/r 463 diff --git a/r b/r
464 new file mode 100644 464 new file mode 100644
465 examine changes to 'r'? [Ynsfdaq?] 465 examine changes to 'r'? [Ynesfdaq?]
466 r 466 r
467 committed changeset 3:899491280810 467 committed changeset 3:899491280810
468 overwriting r expanding keywords 468 overwriting r expanding keywords
469 - status call required for dirstate.normallookup() check 469 - status call required for dirstate.normallookup() check
470 $ hg status r 470 $ hg status r
484 $ hg --verbose record -d '1 13' -m recignored<<EOF 484 $ hg --verbose record -d '1 13' -m recignored<<EOF
485 > y 485 > y
486 > EOF 486 > EOF
487 diff --git a/i b/i 487 diff --git a/i b/i
488 new file mode 100644 488 new file mode 100644
489 examine changes to 'i'? [Ynsfdaq?] 489 examine changes to 'i'? [Ynesfdaq?]
490 i 490 i
491 committed changeset 3:5f40fe93bbdc 491 committed changeset 3:5f40fe93bbdc
492 $ cat i 492 $ cat i
493 $Id$ 493 $Id$
494 $ hg -q rollback 494 $ hg -q rollback