2012-08-18 00:58:18 +04:00
|
|
|
Environment setup for MQ
|
2010-09-26 22:43:21 +04:00
|
|
|
|
|
|
|
$ echo "[extensions]" >> $HGRCPATH
|
|
|
|
$ echo "mq=" >> $HGRCPATH
|
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 ab68b153ce34(*)
- "all changes recorded in the topmost by refreshing" after this patch
(*) ab68b153ce34 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 b46029eb5b29, 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"
2015-10-16 19:15:34 +03:00
|
|
|
$ cat >> $HGRCPATH <<EOF
|
|
|
|
> [defaults]
|
|
|
|
> # explicit date to commit with fixed hashid
|
|
|
|
> qnew = -d "0 0"
|
|
|
|
> qrefresh = -d "0 0"
|
|
|
|
> qfold = -d "0 0"
|
|
|
|
> EOF
|
2010-09-26 22:43:21 +04:00
|
|
|
$ hg init
|
|
|
|
$ hg qinit
|
|
|
|
|
|
|
|
Should fail if no patches applied
|
2014-05-10 19:49:36 +04:00
|
|
|
(this tests also that editor is not invoked if '--edit' is not
|
|
|
|
specified)
|
2010-09-26 22:43:21 +04:00
|
|
|
|
|
|
|
$ hg qrefresh
|
|
|
|
no patches applied
|
|
|
|
[1]
|
|
|
|
$ hg qrefresh -e
|
|
|
|
no patches applied
|
|
|
|
[1]
|
|
|
|
$ hg qnew -m "First commit message" first-patch
|
|
|
|
$ echo aaaa > file
|
|
|
|
$ hg add file
|
2014-05-10 19:49:36 +04:00
|
|
|
$ HGEDITOR=cat hg qrefresh
|
2010-09-26 22:43:21 +04:00
|
|
|
|
|
|
|
Should display 'First commit message'
|
|
|
|
|
|
|
|
$ hg log -l1 --template "{desc}\n"
|
|
|
|
First commit message
|
|
|
|
|
|
|
|
Testing changing message with -m
|
2014-07-15 18:34:13 +04:00
|
|
|
(this tests also that '--edit' can be used with '--message', and
|
|
|
|
that '[committemplate] changeset' definition and commit log specific
|
|
|
|
template keyword 'extramsg' work well)
|
|
|
|
|
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> [committemplate]
|
2014-08-02 16:46:27 +04:00
|
|
|
> listupfiles = {file_adds %
|
|
|
|
> "HG: added {file}\n" }{file_mods %
|
|
|
|
> "HG: changed {file}\n" }{file_dels %
|
|
|
|
> "HG: removed {file}\n" }{if(files, "",
|
|
|
|
> "HG: no files changed\n")}
|
|
|
|
>
|
2014-07-15 18:34:13 +04:00
|
|
|
> changeset = HG: this is customized commit template
|
|
|
|
> {desc}\n\n
|
|
|
|
> HG: Enter commit message. Lines beginning with 'HG:' are removed.
|
|
|
|
> HG: {extramsg}
|
|
|
|
> HG: --
|
|
|
|
> HG: user: {author}
|
2014-08-02 16:46:27 +04:00
|
|
|
> HG: branch '{branch}'\n{listupfiles}
|
2014-07-15 18:34:13 +04:00
|
|
|
> EOF
|
2010-09-26 22:43:21 +04:00
|
|
|
|
|
|
|
$ echo bbbb > file
|
2014-05-31 19:08:32 +04:00
|
|
|
$ HGEDITOR=cat hg qrefresh -m "Second commit message" -e
|
2014-07-15 18:34:13 +04:00
|
|
|
HG: this is customized commit template
|
2014-05-31 19:08:32 +04:00
|
|
|
Second commit message
|
|
|
|
|
|
|
|
|
|
|
|
HG: Enter commit message. Lines beginning with 'HG:' are removed.
|
|
|
|
HG: Leave message empty to use default message.
|
|
|
|
HG: --
|
|
|
|
HG: user: test
|
|
|
|
HG: branch 'default'
|
|
|
|
HG: added file
|
2010-09-26 22:43:21 +04:00
|
|
|
|
2014-07-15 18:34:13 +04:00
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> # disable customizing for subsequent tests
|
|
|
|
> [committemplate]
|
|
|
|
> changeset =
|
|
|
|
> EOF
|
|
|
|
|
2010-09-26 22:43:21 +04:00
|
|
|
Should display 'Second commit message'
|
|
|
|
|
|
|
|
$ hg log -l1 --template "{desc}\n"
|
|
|
|
Second commit message
|
|
|
|
|
|
|
|
Testing changing message with -l
|
|
|
|
|
|
|
|
$ echo "Third commit message" > logfile
|
|
|
|
$ echo " This is the 3rd log message" >> logfile
|
|
|
|
$ echo bbbb > file
|
|
|
|
$ hg qrefresh -l logfile
|
|
|
|
|
|
|
|
Should display 'Third commit message\\\n This is the 3rd log message'
|
|
|
|
|
|
|
|
$ hg log -l1 --template "{desc}\n"
|
|
|
|
Third commit message
|
|
|
|
This is the 3rd log message
|
|
|
|
|
|
|
|
Testing changing message with -l-
|
|
|
|
|
|
|
|
$ hg qnew -m "First commit message" second-patch
|
|
|
|
$ echo aaaa > file2
|
|
|
|
$ hg add file2
|
|
|
|
$ echo bbbb > file2
|
|
|
|
$ (echo "Fifth commit message"; echo " This is the 5th log message") | hg qrefresh -l-
|
|
|
|
|
|
|
|
Should display 'Fifth commit message\\\n This is the 5th log message'
|
|
|
|
|
|
|
|
$ hg log -l1 --template "{desc}\n"
|
|
|
|
Fifth commit message
|
|
|
|
This is the 5th log message
|
2014-05-05 16:26:40 +04:00
|
|
|
|
|
|
|
Test saving last-message.txt:
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/editor.sh << EOF
|
|
|
|
> echo "==== before editing"
|
|
|
|
> cat \$1
|
|
|
|
> echo "===="
|
|
|
|
> (echo; echo "test saving last-message.txt") >> \$1
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/commitfailure.py <<EOF
|
2015-10-08 22:55:45 +03:00
|
|
|
> from mercurial import error
|
2014-05-05 16:26:40 +04:00
|
|
|
> def reposetup(ui, repo):
|
|
|
|
> class commitfailure(repo.__class__):
|
|
|
|
> def commit(self, *args, **kwargs):
|
2015-10-08 22:55:45 +03:00
|
|
|
> raise error.Abort('emulating unexpected abort')
|
2014-05-05 16:26:40 +04:00
|
|
|
> repo.__class__ = commitfailure
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> [extensions]
|
|
|
|
> # this failure occurs before editor invocation
|
|
|
|
> commitfailure = $TESTTMP/commitfailure.py
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ hg qapplied
|
|
|
|
first-patch
|
|
|
|
second-patch
|
|
|
|
$ hg tip --template "{files}\n"
|
|
|
|
file2
|
|
|
|
|
|
|
|
(test that editor is not invoked before transaction starting)
|
|
|
|
|
|
|
|
$ rm -f .hg/last-message.txt
|
|
|
|
$ HGEDITOR="sh $TESTTMP/editor.sh" hg qrefresh -e
|
2015-10-14 10:30:27 +03:00
|
|
|
qrefresh interrupted while patch was popped! (revert --all, qpush to recover)
|
2014-05-05 16:26:40 +04:00
|
|
|
abort: emulating unexpected abort
|
|
|
|
[255]
|
2014-07-21 22:27:24 +04:00
|
|
|
$ test -f .hg/last-message.txt
|
2014-05-05 16:26:40 +04:00
|
|
|
[1]
|
|
|
|
|
|
|
|
(reset applied patches and directory status)
|
|
|
|
|
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> [extensions]
|
|
|
|
> commitfailure = !
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ hg qapplied
|
|
|
|
first-patch
|
|
|
|
$ hg status -A file2
|
|
|
|
? file2
|
|
|
|
$ rm file2
|
|
|
|
$ hg qpush -q second-patch
|
|
|
|
now at: second-patch
|
|
|
|
|
|
|
|
(test that editor is invoked and commit message is saved into
|
|
|
|
"last-message.txt")
|
|
|
|
|
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> [hooks]
|
|
|
|
> # this failure occurs after editor invocation
|
|
|
|
> pretxncommit.unexpectedabort = false
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ rm -f .hg/last-message.txt
|
2014-05-10 19:49:36 +04:00
|
|
|
$ hg status --rev "second-patch^1" -arm
|
|
|
|
A file2
|
2014-05-05 16:26:40 +04:00
|
|
|
$ HGEDITOR="sh $TESTTMP/editor.sh" hg qrefresh -e
|
|
|
|
==== before editing
|
|
|
|
Fifth commit message
|
|
|
|
This is the 5th log message
|
2014-05-10 19:49:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
HG: Enter commit message. Lines beginning with 'HG:' are removed.
|
|
|
|
HG: Leave message empty to use default message.
|
|
|
|
HG: --
|
|
|
|
HG: user: test
|
|
|
|
HG: branch 'default'
|
|
|
|
HG: added file2
|
2014-05-05 16:26:40 +04:00
|
|
|
====
|
2015-11-18 12:36:58 +03:00
|
|
|
note: commit message saved in .hg/last-message.txt
|
2014-05-05 16:26:40 +04:00
|
|
|
transaction abort!
|
|
|
|
rollback completed
|
2015-10-14 10:30:27 +03:00
|
|
|
qrefresh interrupted while patch was popped! (revert --all, qpush to recover)
|
2014-05-05 16:26:40 +04:00
|
|
|
abort: pretxncommit.unexpectedabort hook exited with status 1
|
|
|
|
[255]
|
|
|
|
$ cat .hg/last-message.txt
|
|
|
|
Fifth commit message
|
|
|
|
This is the 5th log message
|
|
|
|
|
2014-05-10 19:49:36 +04:00
|
|
|
|
|
|
|
|
2014-05-05 16:26:40 +04:00
|
|
|
test saving last-message.txt
|
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 ab68b153ce34(*)
- "all changes recorded in the topmost by refreshing" after this patch
(*) ab68b153ce34 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 b46029eb5b29, 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"
2015-10-16 19:15:34 +03:00
|
|
|
|
2016-10-18 00:16:55 +03:00
|
|
|
Test visibility of in-memory dirstate changes outside transaction to
|
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 ab68b153ce34(*)
- "all changes recorded in the topmost by refreshing" after this patch
(*) ab68b153ce34 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 b46029eb5b29, 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"
2015-10-16 19:15:34 +03:00
|
|
|
external process
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/checkvisibility.sh <<EOF
|
|
|
|
> echo "===="
|
|
|
|
> hg parents --template "{rev}:{node|short}\n"
|
|
|
|
> hg status -arm
|
|
|
|
> echo "===="
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
== test visibility to external editor
|
|
|
|
|
|
|
|
$ hg update -C -q first-patch
|
|
|
|
$ rm -f file2
|
|
|
|
$ hg qpush -q second-patch --config hooks.pretxncommit.unexpectedabort=
|
|
|
|
now at: second-patch
|
|
|
|
$ echo bbbb >> file2
|
|
|
|
|
|
|
|
$ sh "$TESTTMP/checkvisibility.sh"
|
|
|
|
====
|
|
|
|
1:e30108269082
|
|
|
|
M file2
|
|
|
|
====
|
|
|
|
|
2015-11-16 22:37:03 +03:00
|
|
|
$ HGEDITOR="sh \"$TESTTMP/checkvisibility.sh\"" hg qrefresh -e
|
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 ab68b153ce34(*)
- "all changes recorded in the topmost by refreshing" after this patch
(*) ab68b153ce34 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 b46029eb5b29, 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"
2015-10-16 19:15:34 +03:00
|
|
|
====
|
|
|
|
0:25e397dabed2
|
|
|
|
A file2
|
|
|
|
====
|
2015-11-18 12:36:58 +03:00
|
|
|
note: commit message saved in .hg/last-message.txt
|
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 ab68b153ce34(*)
- "all changes recorded in the topmost by refreshing" after this patch
(*) ab68b153ce34 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 b46029eb5b29, 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"
2015-10-16 19:15:34 +03:00
|
|
|
transaction abort!
|
|
|
|
rollback completed
|
2015-10-14 10:30:27 +03:00
|
|
|
qrefresh interrupted while patch was popped! (revert --all, qpush to recover)
|
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 ab68b153ce34(*)
- "all changes recorded in the topmost by refreshing" after this patch
(*) ab68b153ce34 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 b46029eb5b29, 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"
2015-10-16 19:15:34 +03:00
|
|
|
abort: pretxncommit.unexpectedabort hook exited with status 1
|
|
|
|
[255]
|
|
|
|
|
|
|
|
(rebuilding at failure of qrefresh bases on rev #0, and it causes
|
|
|
|
dropping status of "file2")
|
|
|
|
|
|
|
|
$ sh "$TESTTMP/checkvisibility.sh"
|
|
|
|
====
|
|
|
|
0:25e397dabed2
|
|
|
|
====
|
2015-10-16 19:15:34 +03:00
|
|
|
|
|
|
|
== test visibility to precommit external hook
|
|
|
|
|
|
|
|
$ hg update -C -q
|
|
|
|
$ rm -f file2
|
|
|
|
$ hg qpush -q second-patch --config hooks.pretxncommit.unexpectedabort=
|
|
|
|
now at: second-patch
|
|
|
|
$ echo bbbb >> file2
|
|
|
|
|
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> [hooks]
|
|
|
|
> precommit.checkvisibility = sh "$TESTTMP/checkvisibility.sh"
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ sh "$TESTTMP/checkvisibility.sh"
|
|
|
|
====
|
|
|
|
1:e30108269082
|
|
|
|
M file2
|
|
|
|
====
|
|
|
|
|
|
|
|
$ hg qrefresh
|
|
|
|
====
|
|
|
|
0:25e397dabed2
|
|
|
|
A file2
|
|
|
|
====
|
|
|
|
transaction abort!
|
|
|
|
rollback completed
|
2015-10-14 10:30:27 +03:00
|
|
|
qrefresh interrupted while patch was popped! (revert --all, qpush to recover)
|
2015-10-16 19:15:34 +03:00
|
|
|
abort: pretxncommit.unexpectedabort hook exited with status 1
|
|
|
|
[255]
|
|
|
|
|
|
|
|
$ sh "$TESTTMP/checkvisibility.sh"
|
|
|
|
====
|
|
|
|
0:25e397dabed2
|
|
|
|
====
|
|
|
|
|
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> [hooks]
|
|
|
|
> precommit.checkvisibility =
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
== test visibility to pretxncommit external hook
|
|
|
|
|
|
|
|
$ hg update -C -q
|
|
|
|
$ rm -f file2
|
|
|
|
$ hg qpush -q second-patch --config hooks.pretxncommit.unexpectedabort=
|
|
|
|
now at: second-patch
|
|
|
|
$ echo bbbb >> file2
|
|
|
|
|
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> [hooks]
|
|
|
|
> pretxncommit.checkvisibility = sh "$TESTTMP/checkvisibility.sh"
|
|
|
|
> # make checkvisibility run before unexpectedabort
|
|
|
|
> priority.pretxncommit.checkvisibility = 10
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ sh "$TESTTMP/checkvisibility.sh"
|
|
|
|
====
|
|
|
|
1:e30108269082
|
|
|
|
M file2
|
|
|
|
====
|
|
|
|
|
|
|
|
$ hg qrefresh
|
|
|
|
====
|
|
|
|
0:25e397dabed2
|
|
|
|
A file2
|
|
|
|
====
|
|
|
|
transaction abort!
|
|
|
|
rollback completed
|
2015-10-14 10:30:27 +03:00
|
|
|
qrefresh interrupted while patch was popped! (revert --all, qpush to recover)
|
2015-10-16 19:15:34 +03:00
|
|
|
abort: pretxncommit.unexpectedabort hook exited with status 1
|
|
|
|
[255]
|
|
|
|
|
|
|
|
$ sh "$TESTTMP/checkvisibility.sh"
|
|
|
|
====
|
|
|
|
0:25e397dabed2
|
|
|
|
====
|
|
|
|
|
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> [hooks]
|
|
|
|
> pretxncommit.checkvisibility =
|
|
|
|
> EOF
|