tests/test-586.t
author A. S. Budden <abudden@gmail.com>
Fri, 30 Mar 2012 22:08:46 +0100
changeset 16324 46b991a1f428
parent 13742 7abab875e647
child 16913 f2719b387380
permissions -rw-r--r--
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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12399
4fee1fd3de9a tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents: 11846
diff changeset
     1
Issue586: removing remote files after merge appears to corrupt the
4fee1fd3de9a tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents: 11846
diff changeset
     2
dirstate
4535
720ae5085ee3 commit: fix bug where dirstate for removed file is confused
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
     3
11846
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
     4
  $ hg init a
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
     5
  $ cd a
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
     6
  $ echo a > a
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
     7
  $ hg ci -Ama
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
     8
  adding a
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
     9
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    10
  $ hg init ../b
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    11
  $ cd ../b
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    12
  $ echo b > b
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    13
  $ hg ci -Amb
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    14
  adding b
4535
720ae5085ee3 commit: fix bug where dirstate for removed file is confused
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    15
11846
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    16
  $ hg pull -f ../a
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    17
  pulling from ../a
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    18
  searching for changes
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    19
  warning: repository is unrelated
13742
7abab875e647 discovery: avoid discovery when local graph is a subset of remote
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 12399
diff changeset
    20
  requesting all changes
11846
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    21
  adding changesets
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    22
  adding manifests
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    23
  adding file changes
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    24
  added 1 changesets with 1 changes to 1 files (+1 heads)
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    25
  (run 'hg heads' to see heads, 'hg merge' to merge)
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    26
  $ hg merge
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    27
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    28
  (branch merge, don't forget to commit)
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    29
  $ hg rm -f a
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    30
  $ hg ci -Amc
4535
720ae5085ee3 commit: fix bug where dirstate for removed file is confused
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    31
11846
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    32
  $ hg st -A
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    33
  C b
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    34
  $ cd ..
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    35
12399
4fee1fd3de9a tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents: 11846
diff changeset
    36
Issue1433: Traceback after two unrelated pull, two move, a merge and
4fee1fd3de9a tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents: 11846
diff changeset
    37
a commit (related to issue586)
4535
720ae5085ee3 commit: fix bug where dirstate for removed file is confused
Matt Mackall <mpm@selenic.com>
parents:
diff changeset
    38
11846
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    39
create test repos
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    40
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    41
  $ hg init repoa
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    42
  $ touch repoa/a
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    43
  $ hg -R repoa ci -Am adda
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    44
  adding a
7564
f1af59451c0c localrepo: fix bad manifest delta generation (issue1433)
Patrick Mezard <pmezard@gmail.com>
parents: 4535
diff changeset
    45
11846
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    46
  $ hg init repob
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    47
  $ touch repob/b
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    48
  $ hg -R repob ci -Am addb
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    49
  adding b
7564
f1af59451c0c localrepo: fix bad manifest delta generation (issue1433)
Patrick Mezard <pmezard@gmail.com>
parents: 4535
diff changeset
    50
11846
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    51
  $ hg init repoc
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    52
  $ cd repoc
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    53
  $ hg pull ../repoa
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    54
  pulling from ../repoa
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    55
  requesting all changes
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    56
  adding changesets
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    57
  adding manifests
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    58
  adding file changes
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    59
  added 1 changesets with 1 changes to 1 files
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    60
  (run 'hg update' to get a working copy)
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    61
  $ hg update
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    62
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    63
  $ mkdir tst
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    64
  $ hg mv * tst
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    65
  $ hg ci -m "import a in tst"
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    66
  $ hg pull -f ../repob
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    67
  pulling from ../repob
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    68
  searching for changes
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    69
  warning: repository is unrelated
13742
7abab875e647 discovery: avoid discovery when local graph is a subset of remote
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 12399
diff changeset
    70
  requesting all changes
11846
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    71
  adding changesets
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    72
  adding manifests
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    73
  adding file changes
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    74
  added 1 changesets with 1 changes to 1 files (+1 heads)
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    75
  (run 'hg heads' to see heads, 'hg merge' to merge)
7564
f1af59451c0c localrepo: fix bad manifest delta generation (issue1433)
Patrick Mezard <pmezard@gmail.com>
parents: 4535
diff changeset
    76
11846
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    77
merge both repos
7564
f1af59451c0c localrepo: fix bad manifest delta generation (issue1433)
Patrick Mezard <pmezard@gmail.com>
parents: 4535
diff changeset
    78
11846
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    79
  $ hg merge
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    80
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    81
  (branch merge, don't forget to commit)
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    82
  $ mkdir src
7564
f1af59451c0c localrepo: fix bad manifest delta generation (issue1433)
Patrick Mezard <pmezard@gmail.com>
parents: 4535
diff changeset
    83
11846
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    84
move b content
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    85
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    86
  $ hg mv b src
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    87
  $ hg ci -m "import b in src"
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    88
  $ hg manifest
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    89
  src/b
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    90
  tst/a
650402ea4a4f tests: unify test-586
Martin Geisler <mg@lazybytes.net>
parents: 7564
diff changeset
    91