Mercurial > hg
annotate tests/test-patch-offset.t @ 26750:9f9ec4abe700
cmdutil: make in-memory changes visible to external editor (issue4378)
Before this patch, external editor process for the commit log can't
view some in-memory changes (especially, of dirstate), because they
aren't written out until the end of transaction (or wlock).
This causes unexpected output of Mercurial commands spawned from that
editor process.
To make in-memory changes visible to external editor process, this
patch does:
- write (or schedule to write) in-memory dirstate changes, and
- set HG_PENDING environment variable, if:
- a transaction is running, and
- there are in-memory changes to be visible
"hg diff" spawned from external editor process for "hg qrefresh"
shows:
- "changes newly imported into the topmost" before 49148d7868df(*)
- "all changes recorded in the topmost by refreshing" after this patch
(*) 49148d7868df changed steps invoking editor process
Even though backward compatibility may be broken, the latter behavior
looks reasonable, because "hg diff" spawned from the editor process
consistently shows "what changes new revision records" regardless of
invocation context.
In fact, issue4378 itself should be resolved by 800e090e9c64, which
made 'repo.transaction()' write in-memory dirstate changes out
explicitly before starting transaction. It also made "hg qrefresh"
imply 'dirstate.write()' before external editor invocation in call
chain below.
- mq.queue.refresh
- strip.strip
- repair.strip
- localrepository.transaction
- dirstate.write
- localrepository.commit
- invoke external editor
Though, this patch has '(issue4378)' in own summary line to indicate
that issues like issue4378 should be fixed by this.
BTW, this patch adds '-m' option to a 'hg ci --amend' execution in
'test-commit-amend.t', to avoid invoking external editor process.
In this case, "unsure" states may be changed to "clean" according to
timestamp or so on. These changes should be written into pending file,
if external editor invocation is required,
Then, writing dirstate changes out breaks stability of test, because
it shows "transaction abort!/rollback completed" occasionally.
Aborting after editor process invocation while commands below may
cause similar instability of tests, too (AFAIK, there is no more such
one, at this revision)
- commit --amend
- without --message/--logfile
- import
- without --message/--logfile,
- without --no-commit,
- without --bypass,
- one of below, and
- patch has no description text, or
- with --edit
- aborting at the 1st patch, which adds or removes file(s)
- if it only changes existing files, status is checked only for
changed files by 'scmutil.matchfiles()', and transition from
"unsure" to "normal" in dirstate doesn't occur (= dirstate
isn't changed, and written out)
- aborting at the 2nd or later patch implies other pending
changes (e.g. changelog), and always causes showing
"transaction abort!/rollback completed"
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 17 Oct 2015 01:15:34 +0900 |
parents | a387b0390082 |
children | 75be14993fda |
rev | line source |
---|---|
10135
9a4034b630c4
patch: better handling of sequence of offset patch hunks (issue1941)
Greg Onufer <gonufer@jazzhaiku.com>
parents:
diff
changeset
|
1 |
12477
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
2 $ cat > writepatterns.py <<EOF |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
3 > import sys |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
4 > |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
5 > path = sys.argv[1] |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
6 > patterns = sys.argv[2:] |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
7 > |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
8 > fp = file(path, 'wb') |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
9 > for pattern in patterns: |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
10 > count = int(pattern[0:-1]) |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
11 > char = pattern[-1] + '\n' |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
12 > fp.write(char*count) |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
13 > fp.close() |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
14 > EOF |
10135
9a4034b630c4
patch: better handling of sequence of offset patch hunks (issue1941)
Greg Onufer <gonufer@jazzhaiku.com>
parents:
diff
changeset
|
15 |
12477
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
16 prepare repo |
10135
9a4034b630c4
patch: better handling of sequence of offset patch hunks (issue1941)
Greg Onufer <gonufer@jazzhaiku.com>
parents:
diff
changeset
|
17 |
12477
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
18 $ hg init a |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
19 $ cd a |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
20 |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
21 These initial lines of Xs were not in the original file used to generate |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
22 the patch. So all the patch hunks need to be applied to a constant offset |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
23 within this file. If the offset isn't tracked then the hunks can be |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
24 applied to the wrong lines of this file. |
10135
9a4034b630c4
patch: better handling of sequence of offset patch hunks (issue1941)
Greg Onufer <gonufer@jazzhaiku.com>
parents:
diff
changeset
|
25 |
12477
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
26 $ python ../writepatterns.py a 34X 10A 1B 10A 1C 10A 1B 10A 1D 10A 1B 10A 1E 10A 1B 10A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
27 $ hg commit -Am adda |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
28 adding a |
10135
9a4034b630c4
patch: better handling of sequence of offset patch hunks (issue1941)
Greg Onufer <gonufer@jazzhaiku.com>
parents:
diff
changeset
|
29 |
12477
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
30 This is a cleaner patch generated via diff |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
31 In this case it reproduces the problem when |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
32 the output of hg export does not |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
33 import patch |
10135
9a4034b630c4
patch: better handling of sequence of offset patch hunks (issue1941)
Greg Onufer <gonufer@jazzhaiku.com>
parents:
diff
changeset
|
34 |
12477
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
35 $ hg import -v -m 'b' -d '2 0' - <<EOF |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
36 > --- a/a 2009-12-08 19:26:17.000000000 -0800 |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
37 > +++ b/a 2009-12-08 19:26:17.000000000 -0800 |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
38 > @@ -9,7 +9,7 @@ |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
39 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
40 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
41 > B |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
42 > -A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
43 > +a |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
44 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
45 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
46 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
47 > @@ -53,7 +53,7 @@ |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
48 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
49 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
50 > B |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
51 > -A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
52 > +a |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
53 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
54 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
55 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
56 > @@ -75,7 +75,7 @@ |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
57 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
58 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
59 > B |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
60 > -A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
61 > +a |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
62 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
63 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
64 > A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
65 > EOF |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
66 applying patch from stdin |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
67 patching file a |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
68 Hunk #1 succeeded at 43 (offset 34 lines). |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
69 Hunk #2 succeeded at 87 (offset 34 lines). |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
70 Hunk #3 succeeded at 109 (offset 34 lines). |
23749
a387b0390082
localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents:
16913
diff
changeset
|
71 committing files: |
12477
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
72 a |
23749
a387b0390082
localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents:
16913
diff
changeset
|
73 committing manifest |
a387b0390082
localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents:
16913
diff
changeset
|
74 committing changelog |
15194
0705f2ac79d6
import: simplify status reporting logic (and make it more I18N-friendly)
Greg Ward <greg@gerg.ca>
parents:
12477
diff
changeset
|
75 created 189885cecb41 |
10135
9a4034b630c4
patch: better handling of sequence of offset patch hunks (issue1941)
Greg Onufer <gonufer@jazzhaiku.com>
parents:
diff
changeset
|
76 |
12477
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
77 compare imported changes against reference file |
10135
9a4034b630c4
patch: better handling of sequence of offset patch hunks (issue1941)
Greg Onufer <gonufer@jazzhaiku.com>
parents:
diff
changeset
|
78 |
12477
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
79 $ python ../writepatterns.py aref 34X 10A 1B 1a 9A 1C 10A 1B 10A 1D 10A 1B 1a 9A 1E 10A 1B 1a 9A |
e68cd3a90599
tests: unify test-patch-offset
Matt Mackall <mpm@selenic.com>
parents:
10265
diff
changeset
|
80 $ diff aref a |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
15194
diff
changeset
|
81 |
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
15194
diff
changeset
|
82 $ cd .. |