2010-09-18 02:03:08 +04:00
|
|
|
commit hooks can see env vars
|
2015-04-20 16:27:55 +03:00
|
|
|
(and post-transaction one are run unlocked)
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2015-05-27 14:56:44 +03:00
|
|
|
|
2015-05-19 22:34:27 +03:00
|
|
|
$ cat > $TESTTMP/txnabort.checkargs.py <<EOF
|
|
|
|
> def showargs(ui, repo, hooktype, **kwargs):
|
2017-07-05 19:09:55 +03:00
|
|
|
> ui.write('%s Python hook: %s\n' % (hooktype, ','.join(sorted(kwargs))))
|
2015-05-19 22:34:27 +03:00
|
|
|
> EOF
|
|
|
|
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg init a
|
|
|
|
$ cd a
|
2012-06-15 23:42:47 +04:00
|
|
|
$ cat > .hg/hgrc <<EOF
|
|
|
|
> [hooks]
|
2015-06-08 23:10:15 +03:00
|
|
|
> commit = sh -c "HG_LOCAL= HG_TAG= printenv.py commit"
|
|
|
|
> commit.b = sh -c "HG_LOCAL= HG_TAG= printenv.py commit.b"
|
|
|
|
> precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= printenv.py precommit"
|
|
|
|
> pretxncommit = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxncommit"
|
2012-06-15 23:42:47 +04:00
|
|
|
> pretxncommit.tip = hg -q tip
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
> pre-identify = sh -c "printenv.py pre-identify 1"
|
|
|
|
> pre-cat = sh -c "printenv.py pre-cat"
|
|
|
|
> post-cat = sh -c "printenv.py post-cat"
|
2015-06-08 23:10:15 +03:00
|
|
|
> pretxnopen = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnopen"
|
|
|
|
> pretxnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnclose"
|
|
|
|
> txnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py txnclose"
|
2015-05-19 22:34:27 +03:00
|
|
|
> txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs
|
2015-06-08 23:10:15 +03:00
|
|
|
> txnabort.1 = sh -c "HG_LOCAL= HG_TAG= printenv.py txnabort"
|
2015-04-20 20:43:10 +03:00
|
|
|
> txnclose.checklock = sh -c "hg debuglock > /dev/null"
|
2012-06-15 23:42:47 +04:00
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
$ echo a > a
|
|
|
|
$ hg add a
|
2010-09-03 01:22:51 +04:00
|
|
|
$ hg commit -m a
|
2017-03-31 12:53:56 +03:00
|
|
|
precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=0000000000000000000000000000000000000000
|
|
|
|
pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
pretxncommit hook: HG_HOOKNAME=pretxncommit HG_HOOKTYPE=pretxncommit HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a
|
2010-09-03 01:22:51 +04:00
|
|
|
0:cb9a9f314b8b
|
2017-03-31 12:53:56 +03:00
|
|
|
pretxnclose hook: HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_PHASES_MOVED=1 HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
txnclose hook: HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_PHASES_MOVED=1 HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
commit hook: HG_HOOKNAME=commit HG_HOOKTYPE=commit HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
|
|
|
|
commit.b hook: HG_HOOKNAME=commit.b HG_HOOKTYPE=commit HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ hg clone . ../b
|
|
|
|
updating to branch default
|
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ cd ../b
|
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
changegroup hooks can see env vars
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2012-06-15 23:42:47 +04:00
|
|
|
$ cat > .hg/hgrc <<EOF
|
|
|
|
> [hooks]
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
> prechangegroup = sh -c "printenv.py prechangegroup"
|
|
|
|
> changegroup = sh -c "printenv.py changegroup"
|
|
|
|
> incoming = sh -c "printenv.py incoming"
|
2012-06-15 23:42:47 +04:00
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
pretxncommit and commit hooks can see both parents of merge
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ cd ../a
|
|
|
|
$ echo b >> a
|
|
|
|
$ hg commit -m a1 -d "1 0"
|
2017-03-31 12:53:56 +03:00
|
|
|
precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
|
|
|
|
pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
pretxncommit hook: HG_HOOKNAME=pretxncommit HG_HOOKTYPE=pretxncommit HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
|
2010-09-03 01:22:51 +04:00
|
|
|
1:ab228980c14d
|
2017-03-31 12:53:56 +03:00
|
|
|
pretxnclose hook: HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
txnclose hook: HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
commit hook: HG_HOOKNAME=commit HG_HOOKTYPE=commit HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
|
|
|
|
commit.b hook: HG_HOOKNAME=commit.b HG_HOOKTYPE=commit HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg update -C 0
|
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ echo b > b
|
|
|
|
$ hg add b
|
|
|
|
$ hg commit -m b -d '1 0'
|
2017-03-31 12:53:56 +03:00
|
|
|
precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
|
|
|
|
pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
pretxncommit hook: HG_HOOKNAME=pretxncommit HG_HOOKTYPE=pretxncommit HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
|
2010-09-03 01:22:51 +04:00
|
|
|
2:ee9deb46ab31
|
2017-03-31 12:53:56 +03:00
|
|
|
pretxnclose hook: HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
txnclose hook: HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
commit hook: HG_HOOKNAME=commit HG_HOOKTYPE=commit HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
|
|
|
|
commit.b hook: HG_HOOKNAME=commit.b HG_HOOKTYPE=commit HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg merge 1
|
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
(branch merge, don't forget to commit)
|
|
|
|
$ hg commit -m merge -d '2 0'
|
2017-03-31 12:53:56 +03:00
|
|
|
precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
|
|
|
|
pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
pretxncommit hook: HG_HOOKNAME=pretxncommit HG_HOOKTYPE=pretxncommit HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a
|
2010-09-03 01:22:51 +04:00
|
|
|
3:07f3376c1e65
|
2017-03-31 12:53:56 +03:00
|
|
|
pretxnclose hook: HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
txnclose hook: HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
commit hook: HG_HOOKNAME=commit HG_HOOKTYPE=commit HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
|
|
|
|
commit.b hook: HG_HOOKNAME=commit.b HG_HOOKTYPE=commit HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
test generic hooks
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ hg id
|
identify: add template support
This is based on a patch proposed last year by Mathias De Maré[1], with a few
changes.
- Tags and bookmarks are now formatted lists, for more flexible queries.
- The templater is populated whether or not [-nibtB] is specified. (Plain
output is unchanged.) This seems more consistent with other templated
commands.
- The 'id' property is a string, instead of a list.
- The parents of 'wdir()' have their own list of attributes.
I left 'id' as a string because it seems very useful for generating version
info. It's also a bit strange because the value and meaning changes depending
on whether or not --debug is passed (short vs full hash), whether the revision
is a merge or not (one hash or two, separated by a '+'), the working directory
or not (node vs p1node), and local or not (remote defaults to tip, and never has
'+'). The equivalent string built with {rev} seems much less useful, and I
couldn't think of a reasonable name, so I left it out.
The discussion seemed to be pointing towards having a list of nodes, with more
than one entry for a merge. It seems simpler to give the nodes a name, and use
{node} for the actual commit probed, especially now that there is a virtual node
for 'wdir()'.
Yuya mentioned using fm.nested() in that thread, so I did for the parent nodes.
I'm not sure if the plan is to fill in all of the context attributes in these
items, or if these nested items should simply be made {p1node} and {p1rev}.
I used ':' as the tag separator for consistency with {tags} in the log
templater. Likewise, bookmarks are separated by a space for consistency with
the corresponding log template.
[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-August/087039.html
2017-06-25 06:09:21 +03:00
|
|
|
pre-identify hook: HG_ARGS=id HG_HOOKNAME=pre-identify HG_HOOKTYPE=pre-identify HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None, 'template': ''} HG_PATS=[]
|
2013-04-17 01:39:37 +04:00
|
|
|
abort: pre-identify hook exited with status 1
|
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg cat b
|
2017-05-25 15:53:44 +03:00
|
|
|
pre-cat hook: HG_ARGS=cat b HG_HOOKNAME=pre-cat HG_HOOKTYPE=pre-cat HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': '', 'template': ''} HG_PATS=['b']
|
2010-08-12 14:38:31 +04:00
|
|
|
b
|
2017-05-25 15:53:44 +03:00
|
|
|
post-cat hook: HG_ARGS=cat b HG_HOOKNAME=post-cat HG_HOOKTYPE=post-cat HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': '', 'template': ''} HG_PATS=['b'] HG_RESULT=0
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ cd ../b
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
2017-03-31 12:53:56 +03:00
|
|
|
prechangegroup hook: HG_HOOKNAME=prechangegroup HG_HOOKTYPE=prechangegroup HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
|
2010-08-12 14:38:31 +04:00
|
|
|
adding changesets
|
|
|
|
adding manifests
|
|
|
|
adding file changes
|
|
|
|
added 3 changesets with 2 changes to 2 files
|
2017-10-12 10:39:50 +03:00
|
|
|
new changesets ab228980c14d:07f3376c1e65
|
2017-03-31 12:53:56 +03:00
|
|
|
changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_NODE_LAST=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
|
|
|
|
incoming hook: HG_HOOKNAME=incoming HG_HOOKTYPE=incoming HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
|
|
|
|
incoming hook: HG_HOOKNAME=incoming HG_HOOKTYPE=incoming HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
|
|
|
|
incoming hook: HG_HOOKNAME=incoming HG_HOOKTYPE=incoming HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
|
2010-08-12 14:38:31 +04:00
|
|
|
(run 'hg update' to get a working copy)
|
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
tag hooks can see env vars
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ cd ../a
|
2012-06-15 23:42:47 +04:00
|
|
|
$ cat >> .hg/hgrc <<EOF
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
> pretag = sh -c "printenv.py pretag"
|
2015-06-08 23:10:15 +03:00
|
|
|
> tag = sh -c "HG_PARENT1= HG_PARENT2= printenv.py tag"
|
2012-06-15 23:42:47 +04:00
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg tag -d '3 0' a
|
2017-03-31 12:53:56 +03:00
|
|
|
pretag hook: HG_HOOKNAME=pretag HG_HOOKTYPE=pretag HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
|
|
|
|
precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
|
|
|
|
pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
pretxncommit hook: HG_HOOKNAME=pretxncommit HG_HOOKTYPE=pretxncommit HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a
|
2010-09-03 01:22:51 +04:00
|
|
|
4:539e4b31b6dc
|
2017-03-31 12:53:56 +03:00
|
|
|
pretxnclose hook: HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
tag hook: HG_HOOKNAME=tag HG_HOOKTYPE=tag HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
|
|
|
|
txnclose hook: HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
commit hook: HG_HOOKNAME=commit HG_HOOKTYPE=commit HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
|
|
|
|
commit.b hook: HG_HOOKNAME=commit.b HG_HOOKTYPE=commit HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg tag -l la
|
2017-03-31 12:53:56 +03:00
|
|
|
pretag hook: HG_HOOKNAME=pretag HG_HOOKTYPE=pretag HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
|
|
|
|
tag hook: HG_HOOKNAME=tag HG_HOOKTYPE=tag HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
pretag hook can forbid tagging
|
2010-08-12 14:38:31 +04:00
|
|
|
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> pretag.forbid = sh -c "printenv.py pretag.forbid 1"
|
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg tag -d '4 0' fa
|
2017-03-31 12:53:56 +03:00
|
|
|
pretag hook: HG_HOOKNAME=pretag HG_HOOKTYPE=pretag HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
|
|
|
|
pretag.forbid hook: HG_HOOKNAME=pretag.forbid HG_HOOKTYPE=pretag HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
|
2010-08-12 14:38:31 +04:00
|
|
|
abort: pretag.forbid hook exited with status 1
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg tag -l fla
|
2017-03-31 12:53:56 +03:00
|
|
|
pretag hook: HG_HOOKNAME=pretag HG_HOOKTYPE=pretag HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
|
|
|
|
pretag.forbid hook: HG_HOOKNAME=pretag.forbid HG_HOOKTYPE=pretag HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
|
2010-08-12 14:38:31 +04:00
|
|
|
abort: pretag.forbid hook exited with status 1
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
pretxncommit hook can see changeset, can roll back txn, changeset no
|
|
|
|
more there after
|
2010-08-12 14:38:31 +04:00
|
|
|
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> pretxncommit.forbid0 = sh -c "hg tip -q"
|
|
|
|
> pretxncommit.forbid1 = sh -c "printenv.py pretxncommit.forbid 1"
|
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
$ echo z > z
|
|
|
|
$ hg add z
|
|
|
|
$ hg -q tip
|
2010-09-03 01:22:51 +04:00
|
|
|
4:539e4b31b6dc
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg commit -m 'fail' -d '4 0'
|
2017-03-31 12:53:56 +03:00
|
|
|
precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
|
|
|
|
pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
|
|
|
pretxncommit hook: HG_HOOKNAME=pretxncommit HG_HOOKTYPE=pretxncommit HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
|
2010-09-03 01:22:51 +04:00
|
|
|
5:6f611f8018c1
|
|
|
|
5:6f611f8018c1
|
2017-03-31 12:53:56 +03:00
|
|
|
pretxncommit.forbid hook: HG_HOOKNAME=pretxncommit.forbid1 HG_HOOKTYPE=pretxncommit HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
|
2010-08-12 14:38:31 +04:00
|
|
|
transaction abort!
|
2017-07-05 19:09:55 +03:00
|
|
|
txnabort Python hook: txnid,txnname
|
2017-03-31 12:53:56 +03:00
|
|
|
txnabort hook: HG_HOOKNAME=txnabort.1 HG_HOOKTYPE=txnabort HG_TXNID=TXN:$ID$ HG_TXNNAME=commit
|
2010-08-12 14:38:31 +04:00
|
|
|
rollback completed
|
|
|
|
abort: pretxncommit.forbid1 hook exited with status 1
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg -q tip
|
2010-09-03 01:22:51 +04:00
|
|
|
4:539e4b31b6dc
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2014-11-08 20:08:09 +03:00
|
|
|
(Check that no 'changelog.i.a' file were left behind)
|
|
|
|
|
|
|
|
$ ls -1 .hg/store/
|
|
|
|
00changelog.i
|
|
|
|
00manifest.i
|
|
|
|
data
|
|
|
|
fncache
|
|
|
|
journal.phaseroots
|
|
|
|
phaseroots
|
|
|
|
undo
|
2015-01-17 05:34:14 +03:00
|
|
|
undo.backup.fncache
|
|
|
|
undo.backupfiles
|
2014-11-08 20:08:09 +03:00
|
|
|
undo.phaseroots
|
|
|
|
|
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
precommit hook can prevent commit
|
2010-08-12 14:38:31 +04:00
|
|
|
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> precommit.forbid = sh -c "printenv.py precommit.forbid 1"
|
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg commit -m 'fail' -d '4 0'
|
2017-03-31 12:53:56 +03:00
|
|
|
precommit hook: HG_HOOKNAME=precommit HG_HOOKTYPE=precommit HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
|
|
|
|
precommit.forbid hook: HG_HOOKNAME=precommit.forbid HG_HOOKTYPE=precommit HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
|
2010-08-12 14:38:31 +04:00
|
|
|
abort: precommit.forbid hook exited with status 1
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg -q tip
|
2010-09-03 01:22:51 +04:00
|
|
|
4:539e4b31b6dc
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
preupdate hook can prevent update
|
2010-08-12 14:38:31 +04:00
|
|
|
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> preupdate = sh -c "printenv.py preupdate"
|
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg update 1
|
2017-03-31 12:53:56 +03:00
|
|
|
preupdate hook: HG_HOOKNAME=preupdate HG_HOOKTYPE=preupdate HG_PARENT1=ab228980c14d
|
2010-08-12 14:38:31 +04:00
|
|
|
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
|
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
update hook
|
2010-08-12 14:38:31 +04:00
|
|
|
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> update = sh -c "printenv.py update"
|
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg update
|
2017-03-31 12:53:56 +03:00
|
|
|
preupdate hook: HG_HOOKNAME=preupdate HG_HOOKTYPE=preupdate HG_PARENT1=539e4b31b6dc
|
|
|
|
update hook: HG_ERROR=0 HG_HOOKNAME=update HG_HOOKTYPE=update HG_PARENT1=539e4b31b6dc
|
merge: make in-memory changes visible to external update hooks
c67339617276 (while 3.4 code-freeze) made all 'update' hooks run after
releasing wlock for visibility of in-memory dirstate changes. But this
breaks paired invocation of 'preupdate' and 'update' hooks.
For example, 'hg backout --merge' for TARGET revision, which isn't
parent of CURRENT, consists of steps below:
1. update from CURRENT to TARGET
2. commit BACKOUT revision, which backs TARGET out
3. update from BACKOUT to CURRENT
4. merge TARGET into CURRENT
Then, we expects hooks to run in the order below:
- 'preupdate' on CURRENT for (1)
- 'update' on TARGET for (1)
- 'preupdate' on BACKOUT for (3)
- 'update' on CURRENT for (3)
- 'preupdate' on TARGET for (4)
- 'update' on CURRENT/TARGET for (4)
But hooks actually run in the order below:
- 'preupdate' on CURRENT for (1)
- 'preupdate' on BACKOUT for (3)
- 'preupdate' on TARGET for (4)
- 'update' on TARGET for (1), but actually on CURRENT/TARGET
- 'update' on CURRENT for (3), but actually on CURRENT/TARGET
- 'update' on CURRENT for (4), but actually on CURRENT/TARGET
Root cause of the issue focused by c67339617276 is that external
'update' hook process can't view in-memory changes (especially, of
dirstate), because they aren't written out until the end of
transaction (or wlock).
Now, hooks can be invoked just after updating, because previous
patches made in-memory changes visible to external process.
This patch may break backward compatibility from the point of view of
"scheduling hook execution", but should be reasonable because 'update'
hooks had been executed in this order before 3.4.
This patch tests "hg backout" and "hg unshelve", because the former
activates the transaction before 'update' hook invocation, but the
former doesn't.
2015-10-16 19:15:34 +03:00
|
|
|
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2011-05-01 13:12:36 +04:00
|
|
|
pushkey hook
|
|
|
|
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> pushkey = sh -c "printenv.py pushkey"
|
|
|
|
> EOF
|
2011-05-01 13:12:36 +04:00
|
|
|
$ cd ../b
|
|
|
|
$ hg bookmark -r null foo
|
|
|
|
$ hg push -B foo ../a
|
|
|
|
pushing to ../a
|
|
|
|
searching for changes
|
|
|
|
no changes found
|
2017-03-31 12:53:56 +03:00
|
|
|
pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=push
|
|
|
|
pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_TXNNAME=push HG_URL=file:$TESTTMP/a
|
|
|
|
txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_TXNNAME=push HG_URL=file:$TESTTMP/a
|
2014-09-28 07:51:53 +04:00
|
|
|
exporting bookmark foo
|
2012-01-31 01:56:35 +04:00
|
|
|
[1]
|
2011-05-01 13:12:36 +04:00
|
|
|
$ cd ../a
|
|
|
|
|
|
|
|
listkeys hook
|
|
|
|
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> listkeys = sh -c "printenv.py listkeys"
|
|
|
|
> EOF
|
2011-05-01 13:12:36 +04:00
|
|
|
$ hg bookmark -r null bar
|
2017-03-31 12:53:56 +03:00
|
|
|
pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=bookmark
|
|
|
|
pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_TXNID=TXN:$ID$ HG_TXNNAME=bookmark
|
|
|
|
txnclose hook: HG_BOOKMARK_MOVED=1 HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_TXNID=TXN:$ID$ HG_TXNNAME=bookmark
|
2011-05-01 13:12:36 +04:00
|
|
|
$ cd ../b
|
|
|
|
$ hg pull -B bar ../a
|
|
|
|
pulling from ../a
|
2017-03-31 12:53:56 +03:00
|
|
|
listkeys hook: HG_HOOKNAME=listkeys HG_HOOKTYPE=listkeys HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
|
2011-05-02 21:21:30 +04:00
|
|
|
no changes found
|
2016-05-05 14:57:38 +03:00
|
|
|
adding remote bookmark bar
|
2011-05-01 13:12:36 +04:00
|
|
|
$ cd ../a
|
|
|
|
|
|
|
|
test that prepushkey can prevent incoming keys
|
|
|
|
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> prepushkey = sh -c "printenv.py prepushkey.forbid 1"
|
|
|
|
> EOF
|
2011-05-01 13:12:36 +04:00
|
|
|
$ cd ../b
|
|
|
|
$ hg bookmark -r null baz
|
|
|
|
$ hg push -B baz ../a
|
|
|
|
pushing to ../a
|
|
|
|
searching for changes
|
2017-03-31 12:53:56 +03:00
|
|
|
listkeys hook: HG_HOOKNAME=listkeys HG_HOOKTYPE=listkeys HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
|
|
|
|
listkeys hook: HG_HOOKNAME=listkeys HG_HOOKTYPE=listkeys HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
|
2011-05-01 13:12:36 +04:00
|
|
|
no changes found
|
2017-03-31 12:53:56 +03:00
|
|
|
pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=push
|
2017-10-17 13:38:13 +03:00
|
|
|
prepushkey.forbid hook: HG_BUNDLE2=1 HG_HOOKNAME=prepushkey HG_HOOKTYPE=prepushkey HG_KEY=baz HG_NAMESPACE=bookmark HG_NEW=0000000000000000000000000000000000000000 HG_PUSHKEYCOMPAT=1 HG_SOURCE=push HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
|
|
|
|
abort: prepushkey hook exited with status 1
|
2015-05-28 08:25:33 +03:00
|
|
|
[255]
|
2011-05-01 13:12:36 +04:00
|
|
|
$ cd ../a
|
|
|
|
|
|
|
|
test that prelistkeys can prevent listing keys
|
|
|
|
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> prelistkeys = sh -c "printenv.py prelistkeys.forbid 1"
|
|
|
|
> EOF
|
2011-05-01 13:12:36 +04:00
|
|
|
$ hg bookmark -r null quux
|
2017-03-31 12:53:56 +03:00
|
|
|
pretxnopen hook: HG_HOOKNAME=pretxnopen HG_HOOKTYPE=pretxnopen HG_TXNID=TXN:$ID$ HG_TXNNAME=bookmark
|
|
|
|
pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_HOOKNAME=pretxnclose HG_HOOKTYPE=pretxnclose HG_PENDING=$TESTTMP/a HG_TXNID=TXN:$ID$ HG_TXNNAME=bookmark
|
|
|
|
txnclose hook: HG_BOOKMARK_MOVED=1 HG_HOOKNAME=txnclose HG_HOOKTYPE=txnclose HG_TXNID=TXN:$ID$ HG_TXNNAME=bookmark
|
2011-05-01 13:12:36 +04:00
|
|
|
$ cd ../b
|
|
|
|
$ hg pull -B quux ../a
|
|
|
|
pulling from ../a
|
2017-03-31 12:53:56 +03:00
|
|
|
prelistkeys.forbid hook: HG_HOOKNAME=prelistkeys HG_HOOKTYPE=prelistkeys HG_NAMESPACE=bookmarks
|
2011-05-01 13:12:36 +04:00
|
|
|
abort: prelistkeys hook exited with status 1
|
|
|
|
[255]
|
|
|
|
$ cd ../a
|
2013-03-30 06:52:02 +04:00
|
|
|
$ rm .hg/hgrc
|
2011-05-01 13:12:36 +04:00
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
prechangegroup hook can prevent incoming changes
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ cd ../b
|
|
|
|
$ hg -q tip
|
2010-09-03 01:22:51 +04:00
|
|
|
3:07f3376c1e65
|
2012-06-15 23:42:47 +04:00
|
|
|
$ cat > .hg/hgrc <<EOF
|
|
|
|
> [hooks]
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
> prechangegroup.forbid = sh -c "printenv.py prechangegroup.forbid 1"
|
2012-06-15 23:42:47 +04:00
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
2017-03-31 12:53:56 +03:00
|
|
|
prechangegroup.forbid hook: HG_HOOKNAME=prechangegroup.forbid HG_HOOKTYPE=prechangegroup HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
|
2010-08-12 14:38:31 +04:00
|
|
|
abort: prechangegroup.forbid hook exited with status 1
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
pretxnchangegroup hook can see incoming changes, can roll back txn,
|
|
|
|
incoming changes no longer there after
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2012-06-15 23:42:47 +04:00
|
|
|
$ cat > .hg/hgrc <<EOF
|
|
|
|
> [hooks]
|
|
|
|
> pretxnchangegroup.forbid0 = hg tip -q
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
> pretxnchangegroup.forbid1 = sh -c "printenv.py pretxnchangegroup.forbid 1"
|
2012-06-15 23:42:47 +04:00
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
|
|
|
adding changesets
|
|
|
|
adding manifests
|
|
|
|
adding file changes
|
|
|
|
added 1 changesets with 1 changes to 1 files
|
2011-02-18 05:35:01 +03:00
|
|
|
4:539e4b31b6dc
|
2017-03-31 12:53:56 +03:00
|
|
|
pretxnchangegroup.forbid hook: HG_HOOKNAME=pretxnchangegroup.forbid1 HG_HOOKTYPE=pretxnchangegroup HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_NODE_LAST=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_TXNID=TXN:$ID$ HG_URL=file:$TESTTMP/a
|
2010-08-12 14:38:31 +04:00
|
|
|
transaction abort!
|
|
|
|
rollback completed
|
|
|
|
abort: pretxnchangegroup.forbid1 hook exited with status 1
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg -q tip
|
2010-09-03 01:22:51 +04:00
|
|
|
3:07f3376c1e65
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
outgoing hooks can see env vars
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ rm .hg/hgrc
|
2012-06-15 23:42:47 +04:00
|
|
|
$ cat > ../a/.hg/hgrc <<EOF
|
|
|
|
> [hooks]
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
> preoutgoing = sh -c "printenv.py preoutgoing"
|
|
|
|
> outgoing = sh -c "printenv.py outgoing"
|
2012-06-15 23:42:47 +04:00
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
2017-03-31 12:53:56 +03:00
|
|
|
preoutgoing hook: HG_HOOKNAME=preoutgoing HG_HOOKTYPE=preoutgoing HG_SOURCE=pull
|
|
|
|
outgoing hook: HG_HOOKNAME=outgoing HG_HOOKTYPE=outgoing HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull
|
2015-05-27 14:56:44 +03:00
|
|
|
adding changesets
|
2010-08-12 14:38:31 +04:00
|
|
|
adding manifests
|
|
|
|
adding file changes
|
|
|
|
added 1 changesets with 1 changes to 1 files
|
2012-05-12 19:00:01 +04:00
|
|
|
adding remote bookmark quux
|
2017-10-12 10:39:50 +03:00
|
|
|
new changesets 539e4b31b6dc
|
2010-08-12 14:38:31 +04:00
|
|
|
(run 'hg update' to get a working copy)
|
|
|
|
$ hg rollback
|
2011-02-10 11:03:06 +03:00
|
|
|
repository tip rolled back to revision 3 (undo pull)
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
preoutgoing hook can prevent outgoing changes
|
2010-08-12 14:38:31 +04:00
|
|
|
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
$ cat >> ../a/.hg/hgrc <<EOF
|
|
|
|
> preoutgoing.forbid = sh -c "printenv.py preoutgoing.forbid 1"
|
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
2017-03-31 12:53:56 +03:00
|
|
|
preoutgoing hook: HG_HOOKNAME=preoutgoing HG_HOOKTYPE=preoutgoing HG_SOURCE=pull
|
|
|
|
preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid HG_HOOKTYPE=preoutgoing HG_SOURCE=pull
|
2010-08-12 14:38:31 +04:00
|
|
|
abort: preoutgoing.forbid hook exited with status 1
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
outgoing hooks work for local clones
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ cd ..
|
2012-06-15 23:42:47 +04:00
|
|
|
$ cat > a/.hg/hgrc <<EOF
|
|
|
|
> [hooks]
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
> preoutgoing = sh -c "printenv.py preoutgoing"
|
|
|
|
> outgoing = sh -c "printenv.py outgoing"
|
2012-06-15 23:42:47 +04:00
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg clone a c
|
2017-03-31 12:53:56 +03:00
|
|
|
preoutgoing hook: HG_HOOKNAME=preoutgoing HG_HOOKTYPE=preoutgoing HG_SOURCE=clone
|
|
|
|
outgoing hook: HG_HOOKNAME=outgoing HG_HOOKTYPE=outgoing HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone
|
2010-08-12 14:38:31 +04:00
|
|
|
updating to branch default
|
|
|
|
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ rm -rf c
|
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
preoutgoing hook can prevent outgoing changes for local clones
|
2010-08-12 14:38:31 +04:00
|
|
|
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
$ cat >> a/.hg/hgrc <<EOF
|
|
|
|
> preoutgoing.forbid = sh -c "printenv.py preoutgoing.forbid 1"
|
|
|
|
> EOF
|
2010-08-12 14:38:31 +04:00
|
|
|
$ hg clone a zzz
|
2017-03-31 12:53:56 +03:00
|
|
|
preoutgoing hook: HG_HOOKNAME=preoutgoing HG_HOOKTYPE=preoutgoing HG_SOURCE=clone
|
|
|
|
preoutgoing.forbid hook: HG_HOOKNAME=preoutgoing.forbid HG_HOOKTYPE=preoutgoing HG_SOURCE=clone
|
2010-08-12 14:38:31 +04:00
|
|
|
abort: preoutgoing.forbid hook exited with status 1
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2012-06-15 23:42:47 +04:00
|
|
|
|
|
|
|
$ cd "$TESTTMP/b"
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ cat > hooktests.py <<EOF
|
2017-06-15 21:22:25 +03:00
|
|
|
> from __future__ import print_function
|
2015-10-08 22:55:45 +03:00
|
|
|
> from mercurial import error
|
2010-08-12 14:38:31 +04:00
|
|
|
>
|
|
|
|
> uncallable = 0
|
|
|
|
>
|
2017-10-04 00:35:24 +03:00
|
|
|
> def printargs(ui, args):
|
2010-08-12 14:38:31 +04:00
|
|
|
> a = list(args.items())
|
|
|
|
> a.sort()
|
2017-10-04 00:35:24 +03:00
|
|
|
> ui.write('hook args:\n')
|
2010-08-12 14:38:31 +04:00
|
|
|
> for k, v in a:
|
2017-10-04 00:35:24 +03:00
|
|
|
> ui.write(' %s %s\n' % (k, v))
|
2010-08-12 14:38:31 +04:00
|
|
|
>
|
2017-10-04 00:35:24 +03:00
|
|
|
> def passhook(ui, repo, **args):
|
|
|
|
> printargs(ui, args)
|
2010-08-12 14:38:31 +04:00
|
|
|
>
|
2017-10-04 00:35:24 +03:00
|
|
|
> def failhook(ui, repo, **args):
|
|
|
|
> printargs(ui, args)
|
2010-08-12 14:38:31 +04:00
|
|
|
> return True
|
|
|
|
>
|
|
|
|
> class LocalException(Exception):
|
|
|
|
> pass
|
|
|
|
>
|
|
|
|
> def raisehook(**args):
|
|
|
|
> raise LocalException('exception from hook')
|
|
|
|
>
|
|
|
|
> def aborthook(**args):
|
2015-10-08 22:55:45 +03:00
|
|
|
> raise error.Abort('raise abort from hook')
|
2010-08-12 14:38:31 +04:00
|
|
|
>
|
|
|
|
> def brokenhook(**args):
|
|
|
|
> return 1 + {}
|
|
|
|
>
|
2011-06-13 01:19:26 +04:00
|
|
|
> def verbosehook(ui, **args):
|
|
|
|
> ui.note('verbose output from hook\n')
|
|
|
|
>
|
2012-01-19 05:14:06 +04:00
|
|
|
> def printtags(ui, repo, **args):
|
2017-10-04 00:35:24 +03:00
|
|
|
> ui.write('%s\n' % sorted(repo.tags()))
|
2012-01-19 05:14:06 +04:00
|
|
|
>
|
2010-08-12 14:38:31 +04:00
|
|
|
> class container:
|
|
|
|
> unreachable = 1
|
|
|
|
> EOF
|
|
|
|
|
2016-02-13 01:50:10 +03:00
|
|
|
$ cat > syntaxerror.py << EOF
|
|
|
|
> (foo
|
|
|
|
> EOF
|
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
test python hooks
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2012-06-15 23:42:47 +04:00
|
|
|
#if windows
|
|
|
|
$ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
|
|
|
|
#else
|
|
|
|
$ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
|
|
|
|
#endif
|
2010-08-12 14:38:31 +04:00
|
|
|
$ export PYTHONPATH
|
|
|
|
|
|
|
|
$ echo '[hooks]' > ../a/.hg/hgrc
|
|
|
|
$ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
|
|
|
|
$ hg pull ../a 2>&1 | grep 'raised an exception'
|
|
|
|
error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
|
|
|
|
|
|
|
|
$ echo '[hooks]' > ../a/.hg/hgrc
|
|
|
|
$ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
|
|
|
|
$ hg pull ../a 2>&1 | grep 'raised an exception'
|
|
|
|
error: preoutgoing.raise hook raised an exception: exception from hook
|
|
|
|
|
|
|
|
$ echo '[hooks]' > ../a/.hg/hgrc
|
|
|
|
$ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
|
|
|
error: preoutgoing.abort hook failed: raise abort from hook
|
|
|
|
abort: raise abort from hook
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ echo '[hooks]' > ../a/.hg/hgrc
|
|
|
|
$ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
|
|
|
hook args:
|
|
|
|
hooktype preoutgoing
|
|
|
|
source pull
|
|
|
|
abort: preoutgoing.fail hook failed
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ echo '[hooks]' > ../a/.hg/hgrc
|
|
|
|
$ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
2016-02-12 09:41:20 +03:00
|
|
|
abort: preoutgoing.uncallable hook is invalid: "hooktests.uncallable" is not callable
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ echo '[hooks]' > ../a/.hg/hgrc
|
|
|
|
$ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
2016-02-12 09:41:20 +03:00
|
|
|
abort: preoutgoing.nohook hook is invalid: "hooktests.nohook" is not defined
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ echo '[hooks]' > ../a/.hg/hgrc
|
|
|
|
$ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
2016-02-12 22:34:04 +03:00
|
|
|
abort: preoutgoing.nomodule hook is invalid: "nomodule" not in a module
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ echo '[hooks]' > ../a/.hg/hgrc
|
|
|
|
$ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
2016-02-12 09:41:20 +03:00
|
|
|
abort: preoutgoing.badmodule hook is invalid: import of "nomodule" failed
|
2016-02-12 09:52:23 +03:00
|
|
|
(run with --traceback for stack trace)
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ echo '[hooks]' > ../a/.hg/hgrc
|
|
|
|
$ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
2016-02-12 09:41:20 +03:00
|
|
|
abort: preoutgoing.unreachable hook is invalid: import of "hooktests.container" failed
|
2016-02-12 09:52:23 +03:00
|
|
|
(run with --traceback for stack trace)
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2016-02-13 01:50:10 +03:00
|
|
|
$ echo '[hooks]' > ../a/.hg/hgrc
|
|
|
|
$ echo 'preoutgoing.syntaxerror = python:syntaxerror.syntaxerror' >> ../a/.hg/hgrc
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
|
|
|
abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
|
|
|
|
(run with --traceback for stack trace)
|
|
|
|
[255]
|
|
|
|
|
2016-03-10 21:12:23 +03:00
|
|
|
The second egrep is to filter out lines like ' ^', which are slightly
|
|
|
|
different between Python 2.6 and Python 2.7.
|
|
|
|
$ hg pull ../a --traceback 2>&1 | egrep -v '^( +File| [_a-zA-Z*(])' | egrep -v '^( )+(\^)?$'
|
2016-02-13 01:50:10 +03:00
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
|
|
|
exception from first failed import attempt:
|
|
|
|
Traceback (most recent call last):
|
2016-04-03 10:26:57 +03:00
|
|
|
SyntaxError: * (glob)
|
2016-02-13 01:50:10 +03:00
|
|
|
exception from second failed import attempt:
|
|
|
|
Traceback (most recent call last):
|
|
|
|
ImportError: No module named hgext_syntaxerror
|
|
|
|
Traceback (most recent call last):
|
|
|
|
HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
|
|
|
|
abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
|
|
|
|
|
2010-08-12 14:38:31 +04:00
|
|
|
$ echo '[hooks]' > ../a/.hg/hgrc
|
|
|
|
$ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
|
|
|
hook args:
|
|
|
|
hooktype preoutgoing
|
|
|
|
source pull
|
|
|
|
adding changesets
|
|
|
|
adding manifests
|
|
|
|
adding file changes
|
|
|
|
added 1 changesets with 1 changes to 1 files
|
2012-05-12 19:00:01 +04:00
|
|
|
adding remote bookmark quux
|
2017-10-12 10:39:50 +03:00
|
|
|
new changesets 539e4b31b6dc
|
2010-08-12 14:38:31 +04:00
|
|
|
(run 'hg update' to get a working copy)
|
|
|
|
|
2016-02-12 22:42:18 +03:00
|
|
|
post- python hooks that fail to *run* don't cause an abort
|
|
|
|
$ rm ../a/.hg/hgrc
|
|
|
|
$ echo '[hooks]' > .hg/hgrc
|
|
|
|
$ echo 'post-pull.broken = python:hooktests.brokenhook' >> .hg/hgrc
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
|
|
|
no changes found
|
|
|
|
error: post-pull.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
|
2016-02-12 22:44:35 +03:00
|
|
|
(run with --traceback for stack trace)
|
2016-02-12 22:42:18 +03:00
|
|
|
|
|
|
|
but post- python hooks that fail to *load* do
|
|
|
|
$ echo '[hooks]' > .hg/hgrc
|
|
|
|
$ echo 'post-pull.nomodule = python:nomodule' >> .hg/hgrc
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
|
|
|
no changes found
|
|
|
|
abort: post-pull.nomodule hook is invalid: "nomodule" not in a module
|
|
|
|
[255]
|
|
|
|
|
|
|
|
$ echo '[hooks]' > .hg/hgrc
|
|
|
|
$ echo 'post-pull.badmodule = python:nomodule.nowhere' >> .hg/hgrc
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
|
|
|
no changes found
|
|
|
|
abort: post-pull.badmodule hook is invalid: import of "nomodule" failed
|
|
|
|
(run with --traceback for stack trace)
|
|
|
|
[255]
|
|
|
|
|
|
|
|
$ echo '[hooks]' > .hg/hgrc
|
|
|
|
$ echo 'post-pull.nohook = python:hooktests.nohook' >> .hg/hgrc
|
|
|
|
$ hg pull ../a
|
|
|
|
pulling from ../a
|
|
|
|
searching for changes
|
|
|
|
no changes found
|
|
|
|
abort: post-pull.nohook hook is invalid: "hooktests.nohook" is not defined
|
|
|
|
[255]
|
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
make sure --traceback works
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ echo '[hooks]' > .hg/hgrc
|
|
|
|
$ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
|
|
|
|
|
|
|
|
$ echo aa > a
|
|
|
|
$ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
|
|
|
|
Traceback (most recent call last):
|
|
|
|
|
|
|
|
$ cd ..
|
|
|
|
$ hg init c
|
|
|
|
$ cd c
|
|
|
|
|
|
|
|
$ cat > hookext.py <<EOF
|
2017-10-04 00:35:24 +03:00
|
|
|
> def autohook(ui, **args):
|
|
|
|
> ui.write('Automatically installed hook\n')
|
2010-08-12 14:38:31 +04:00
|
|
|
>
|
|
|
|
> def reposetup(ui, repo):
|
|
|
|
> repo.ui.setconfig("hooks", "commit.auto", autohook)
|
|
|
|
> EOF
|
|
|
|
$ echo '[extensions]' >> .hg/hgrc
|
|
|
|
$ echo 'hookext = hookext.py' >> .hg/hgrc
|
|
|
|
|
|
|
|
$ touch foo
|
|
|
|
$ hg add foo
|
|
|
|
$ hg ci -d '0 0' -m 'add foo'
|
|
|
|
Automatically installed hook
|
|
|
|
$ echo >> foo
|
2010-08-12 14:40:22 +04:00
|
|
|
$ hg ci --debug -d '0 0' -m 'change foo'
|
2014-04-18 15:33:20 +04:00
|
|
|
committing files:
|
2010-08-12 14:38:31 +04:00
|
|
|
foo
|
2014-04-18 15:33:20 +04:00
|
|
|
committing manifest
|
|
|
|
committing changelog
|
2017-05-02 23:27:44 +03:00
|
|
|
updating the branch cache
|
commands: make commit acquire locks before processing (issue4368)
Before this patch, "hg commit" (process A) executes steps below:
1. get current branch heads via 'repo.branchheads()'
- cache 'repo.changelog'
2. invoke 'repo.commit()'
3. acquire wlock
- invalidate 'repo.dirstate'
4. access 'repo.dirstate'
- re-read '.hg/dirstate'
- check validity of parent revisions with 'repo.changelog'
5. invoke 'repo.commitctx()'
6. acquire store lock (slock)
- invalidate 'repo.changelog'
7. do committing
8. release slock
9. release wlock
10. check new branch head (via 'cmdutil.commitstatus()')
If acquisition of wlock at (3) above waits for another "hg commit"
(process B) or so running parallelly to release wlock, process A
causes creating orphan revision, because:
- '.hg/dirstate' refers the revision, which is newly added by
process B, as its parent
- but already cached 'repo.changelog' doesn't contain such revision
- therefore, validating parents of '.hg/dirstate' at (4) above
replaces such revision with 'nullid'
Then, process A creates "orphan" revision, of which parent is "null"
revision.
In addition to it, "created new head" may be shown at the end of
process A unintentionally, if store is updated parallelly, because
both getting branch heads (1) and checking new branch head (10) are
executed outside slock scope.
To avoid this issue, this patch makes "hg commit" acquire wlock and
slock before processing.
This patch resolves the issue between "hg commit" processes, but not
one between "hg commit" and other commands. Subsequent patches resolve
the latter.
Even after this patch, there are still corner case problems below:
- filecache may overlook changes of '.hg/dirstate', and it causes
similar issue (see below for detail)
https://bz.mercurial-scm.org/show_bug.cgi?id=4368#c10
- 3rd party extension may cause similar issue, if it directly uses
'repo.commit()' without acquisition of wlock and slock
This can be fixed by acquisition of slock at the beginning of
'repo.commit()', but it seems suitable for "default" branch
In fact, acquisition of slock itself is already introduced at
"default" branch by ec227b188932, but acquisition is not at the
beginning of 'repo.commit()'.
This patch also changes some tests:
- test-fncache.t needs this tricky wrapping, to release (= forced
failure of) wlock certainly
- order of "hg commit" output is changed by widening scope of locks,
because some hooks are fired after releasing wlock
2015-12-01 21:12:07 +03:00
|
|
|
committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
|
2014-02-15 04:23:12 +04:00
|
|
|
calling hook commit.auto: hgext_hookext.autohook
|
2010-08-12 14:38:31 +04:00
|
|
|
Automatically installed hook
|
|
|
|
|
2010-08-12 14:40:22 +04:00
|
|
|
$ hg showconfig hooks
|
2010-09-23 01:06:02 +04:00
|
|
|
hooks.commit.auto=<function autohook at *> (glob)
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
test python hook configured with python:[file]:[hook] syntax
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ cd ..
|
|
|
|
$ mkdir d
|
|
|
|
$ cd d
|
|
|
|
$ hg init repo
|
|
|
|
$ mkdir hooks
|
|
|
|
|
|
|
|
$ cd hooks
|
|
|
|
$ cat > testhooks.py <<EOF
|
2017-10-04 00:35:24 +03:00
|
|
|
> def testhook(ui, **args):
|
|
|
|
> ui.write('hook works\n')
|
2010-08-12 14:38:31 +04:00
|
|
|
> EOF
|
|
|
|
$ echo '[hooks]' > ../repo/.hg/hgrc
|
|
|
|
$ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
|
|
|
|
|
|
|
|
$ cd ../repo
|
|
|
|
$ hg commit -d '0 0'
|
|
|
|
hook works
|
|
|
|
nothing changed
|
2010-09-17 02:51:32 +04:00
|
|
|
[1]
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2012-07-06 20:41:25 +04:00
|
|
|
$ echo '[hooks]' > .hg/hgrc
|
2012-08-18 00:58:18 +04:00
|
|
|
$ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
|
2012-07-06 20:41:25 +04:00
|
|
|
$ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
|
|
|
|
|
|
|
|
$ hg up null
|
|
|
|
loading update.ne hook failed:
|
2017-12-03 03:33:34 +03:00
|
|
|
abort: $ENOENT$: $TESTTMP/d/repo/nonexistent.py
|
2012-07-06 20:41:25 +04:00
|
|
|
[255]
|
|
|
|
|
|
|
|
$ hg id
|
|
|
|
loading pre-identify.npmd hook failed:
|
|
|
|
abort: No module named repo!
|
|
|
|
[255]
|
|
|
|
|
2010-08-12 14:38:31 +04:00
|
|
|
$ cd ../../b
|
|
|
|
|
2010-09-18 02:03:08 +04:00
|
|
|
make sure --traceback works on hook import failure
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ cat > importfail.py <<EOF
|
|
|
|
> import somebogusmodule
|
|
|
|
> # dereference something in the module to force demandimport to load it
|
|
|
|
> somebogusmodule.whatever
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ echo '[hooks]' > .hg/hgrc
|
|
|
|
$ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
|
|
|
|
|
|
|
|
$ echo a >> a
|
2012-07-30 04:38:29 +04:00
|
|
|
$ hg --traceback commit -ma 2>&1 | egrep -v '^( +File| [a-zA-Z(])'
|
2010-08-12 14:38:31 +04:00
|
|
|
exception from first failed import attempt:
|
|
|
|
Traceback (most recent call last):
|
|
|
|
ImportError: No module named somebogusmodule
|
|
|
|
exception from second failed import attempt:
|
|
|
|
Traceback (most recent call last):
|
|
|
|
ImportError: No module named hgext_importfail
|
|
|
|
Traceback (most recent call last):
|
2016-02-12 09:41:20 +03:00
|
|
|
HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed
|
|
|
|
abort: precommit.importfail hook is invalid: import of "importfail" failed
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2018-01-17 22:50:44 +03:00
|
|
|
commit and update hooks should run after command completion.
|
2010-08-12 14:38:31 +04:00
|
|
|
|
|
|
|
$ echo '[hooks]' > .hg/hgrc
|
|
|
|
$ echo 'commit = hg id' >> .hg/hgrc
|
|
|
|
$ echo 'update = hg id' >> .hg/hgrc
|
|
|
|
$ echo bb > a
|
2010-09-03 01:22:51 +04:00
|
|
|
$ hg ci -ma
|
|
|
|
223eafe2750c tip
|
2018-01-17 22:50:44 +03:00
|
|
|
$ hg up 0
|
2015-08-12 02:26:12 +03:00
|
|
|
cb9a9f314b8b
|
merge: make in-memory changes visible to external update hooks
c67339617276 (while 3.4 code-freeze) made all 'update' hooks run after
releasing wlock for visibility of in-memory dirstate changes. But this
breaks paired invocation of 'preupdate' and 'update' hooks.
For example, 'hg backout --merge' for TARGET revision, which isn't
parent of CURRENT, consists of steps below:
1. update from CURRENT to TARGET
2. commit BACKOUT revision, which backs TARGET out
3. update from BACKOUT to CURRENT
4. merge TARGET into CURRENT
Then, we expects hooks to run in the order below:
- 'preupdate' on CURRENT for (1)
- 'update' on TARGET for (1)
- 'preupdate' on BACKOUT for (3)
- 'update' on CURRENT for (3)
- 'preupdate' on TARGET for (4)
- 'update' on CURRENT/TARGET for (4)
But hooks actually run in the order below:
- 'preupdate' on CURRENT for (1)
- 'preupdate' on BACKOUT for (3)
- 'preupdate' on TARGET for (4)
- 'update' on TARGET for (1), but actually on CURRENT/TARGET
- 'update' on CURRENT for (3), but actually on CURRENT/TARGET
- 'update' on CURRENT for (4), but actually on CURRENT/TARGET
Root cause of the issue focused by c67339617276 is that external
'update' hook process can't view in-memory changes (especially, of
dirstate), because they aren't written out until the end of
transaction (or wlock).
Now, hooks can be invoked just after updating, because previous
patches made in-memory changes visible to external process.
This patch may break backward compatibility from the point of view of
"scheduling hook execution", but should be reasonable because 'update'
hooks had been executed in this order before 3.4.
This patch tests "hg backout" and "hg unshelve", because the former
activates the transaction before 'update' hook invocation, but the
former doesn't.
2015-10-16 19:15:34 +03:00
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
2010-08-12 14:38:31 +04:00
|
|
|
|
2012-08-18 00:58:18 +04:00
|
|
|
make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui
|
2011-06-13 01:19:26 +04:00
|
|
|
that is passed to pre/post hooks
|
|
|
|
|
|
|
|
$ echo '[hooks]' > .hg/hgrc
|
|
|
|
$ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
|
|
|
|
$ hg id
|
|
|
|
cb9a9f314b8b
|
|
|
|
$ hg id --verbose
|
|
|
|
calling hook pre-identify: hooktests.verbosehook
|
|
|
|
verbose output from hook
|
|
|
|
cb9a9f314b8b
|
2012-01-16 00:50:12 +04:00
|
|
|
|
|
|
|
Ensure hooks can be prioritized
|
|
|
|
|
|
|
|
$ echo '[hooks]' > .hg/hgrc
|
|
|
|
$ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
|
|
|
|
$ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
|
|
|
|
$ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
|
|
|
|
$ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
|
|
|
|
$ hg id --verbose
|
|
|
|
calling hook pre-identify.b: hooktests.verbosehook
|
|
|
|
verbose output from hook
|
|
|
|
calling hook pre-identify.a: hooktests.verbosehook
|
|
|
|
verbose output from hook
|
|
|
|
calling hook pre-identify.c: hooktests.verbosehook
|
|
|
|
verbose output from hook
|
|
|
|
cb9a9f314b8b
|
2012-01-19 05:14:06 +04:00
|
|
|
|
|
|
|
new tags must be visible in pretxncommit (issue3210)
|
|
|
|
|
|
|
|
$ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
|
|
|
|
$ hg tag -f foo
|
|
|
|
['a', 'foo', 'tip']
|
|
|
|
|
2015-12-03 03:38:21 +03:00
|
|
|
post-init hooks must not crash (issue4983)
|
|
|
|
This also creates the `to` repo for the next test block.
|
2012-05-11 12:55:33 +04:00
|
|
|
|
|
|
|
$ cd ..
|
2015-12-03 03:38:21 +03:00
|
|
|
$ cat << EOF >> hgrc-with-post-init-hook
|
|
|
|
> [hooks]
|
tests: invoke printenv.py via sh -c for test portability
On Windows platform, invoking printenv.py directly via hook is
problematic, because:
- unless binding between *.py suffix and python runtime, application
selector dialog is displayed, and running test is blocked at each
printenv.py invocations
- it isn't safe to assume binding between *.py suffix and python
runtime, because application binding is easily broken
For example, installing IDE (VisualStudio with Python Tools, or
so) often requires binding between source files and IDE itself.
This patch invokes printenv.py via sh -c for test portability. This is
a kind of follow up for 9e4331825bea, which eliminated explicit
"python" for printenv.py. There are already other 'sh -c "printenv.py"'
in *.t files, and this fix should be reasonable.
This changes were confirmed in cases below:
- without any application binding for *.py suffix
- with binding between *.py suffix and VisualStudio
This patch also replaces "echo + redirection" style with "heredoc"
style, because:
- hook command line is parsed by cmd.exe as shell at first, and
- single quotation can't quote arguments on cmd.exe, therefore,
- "printenv.py foobar" should be quoted by double quotation, but
- nested quoting (or tricky escaping) isn't readable
2016-10-28 20:44:45 +03:00
|
|
|
> post-init = sh -c "printenv.py post-init"
|
2015-12-03 03:38:21 +03:00
|
|
|
> EOF
|
|
|
|
$ HGRCPATH=hgrc-with-post-init-hook hg init to
|
2017-03-31 12:53:56 +03:00
|
|
|
post-init hook: HG_ARGS=init to HG_HOOKNAME=post-init HG_HOOKTYPE=post-init HG_OPTS={'insecure': None, 'remotecmd': '', 'ssh': ''} HG_PATS=['to'] HG_RESULT=0
|
2015-12-03 03:38:21 +03:00
|
|
|
|
|
|
|
new commits must be visible in pretxnchangegroup (issue3428)
|
|
|
|
|
2012-05-11 12:55:33 +04:00
|
|
|
$ echo '[hooks]' >> to/.hg/hgrc
|
2015-11-04 04:13:27 +03:00
|
|
|
$ echo 'prechangegroup = hg --traceback tip' >> to/.hg/hgrc
|
2012-05-11 12:55:33 +04:00
|
|
|
$ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
|
|
|
|
$ echo a >> to/a
|
|
|
|
$ hg --cwd to ci -Ama
|
|
|
|
adding a
|
|
|
|
$ hg clone to from
|
|
|
|
updating to branch default
|
|
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ echo aa >> from/a
|
|
|
|
$ hg --cwd from ci -mb
|
|
|
|
$ hg --cwd from push
|
2017-12-11 06:50:57 +03:00
|
|
|
pushing to $TESTTMP/to
|
2012-05-11 12:55:33 +04:00
|
|
|
searching for changes
|
2015-11-04 04:13:27 +03:00
|
|
|
changeset: 0:cb9a9f314b8b
|
|
|
|
tag: tip
|
|
|
|
user: test
|
|
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
summary: a
|
|
|
|
|
2012-05-11 12:55:33 +04:00
|
|
|
adding changesets
|
|
|
|
adding manifests
|
|
|
|
adding file changes
|
|
|
|
added 1 changesets with 1 changes to 1 files
|
|
|
|
changeset: 1:9836a07b9b9d
|
|
|
|
tag: tip
|
|
|
|
user: test
|
|
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
summary: b
|
|
|
|
|
2016-01-20 02:18:21 +03:00
|
|
|
|
|
|
|
pretxnclose hook failure should abort the transaction
|
|
|
|
|
|
|
|
$ hg init txnfailure
|
|
|
|
$ cd txnfailure
|
|
|
|
$ touch a && hg commit -Aqm a
|
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
|
|
> [hooks]
|
|
|
|
> pretxnclose.error = exit 1
|
|
|
|
> EOF
|
|
|
|
$ hg strip -r 0 --config extensions.strip=
|
|
|
|
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
|
|
|
saved backup bundle to * (glob)
|
|
|
|
transaction abort!
|
|
|
|
rollback completed
|
2016-09-19 19:14:35 +03:00
|
|
|
strip failed, backup bundle stored in * (glob)
|
2016-01-20 02:18:21 +03:00
|
|
|
abort: pretxnclose.error hook exited with status 1
|
|
|
|
[255]
|
|
|
|
$ hg recover
|
|
|
|
no interrupted transaction available
|
|
|
|
[1]
|
2016-04-14 12:41:15 +03:00
|
|
|
$ cd ..
|
|
|
|
|
2017-02-20 19:21:00 +03:00
|
|
|
check whether HG_PENDING makes pending changes only in related
|
|
|
|
repositories visible to an external hook.
|
|
|
|
|
|
|
|
(emulate a transaction running concurrently by copied
|
|
|
|
.hg/store/00changelog.i.a in subsequent test)
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/savepending.sh <<EOF
|
|
|
|
> cp .hg/store/00changelog.i.a .hg/store/00changelog.i.a.saved
|
|
|
|
> exit 1 # to avoid adding new revision for subsequent tests
|
|
|
|
> EOF
|
|
|
|
$ cd a
|
|
|
|
$ hg tip -q
|
|
|
|
4:539e4b31b6dc
|
|
|
|
$ hg --config hooks.pretxnclose="sh $TESTTMP/savepending.sh" commit -m "invisible"
|
|
|
|
transaction abort!
|
|
|
|
rollback completed
|
|
|
|
abort: pretxnclose hook exited with status 1
|
|
|
|
[255]
|
|
|
|
$ cp .hg/store/00changelog.i.a.saved .hg/store/00changelog.i.a
|
|
|
|
|
|
|
|
(check (in)visibility of new changeset while transaction running in
|
|
|
|
repo)
|
|
|
|
|
|
|
|
$ cat > $TESTTMP/checkpending.sh <<EOF
|
|
|
|
> echo '@a'
|
2017-04-01 22:23:26 +03:00
|
|
|
> hg -R "$TESTTMP/a" tip -q
|
2017-02-20 19:21:00 +03:00
|
|
|
> echo '@a/nested'
|
2017-04-01 22:23:26 +03:00
|
|
|
> hg -R "$TESTTMP/a/nested" tip -q
|
2017-02-20 19:21:00 +03:00
|
|
|
> exit 1 # to avoid adding new revision for subsequent tests
|
|
|
|
> EOF
|
|
|
|
$ hg init nested
|
|
|
|
$ cd nested
|
|
|
|
$ echo a > a
|
|
|
|
$ hg add a
|
|
|
|
$ hg --config hooks.pretxnclose="sh $TESTTMP/checkpending.sh" commit -m '#0'
|
|
|
|
@a
|
|
|
|
4:539e4b31b6dc
|
|
|
|
@a/nested
|
|
|
|
0:bf5e395ced2c
|
|
|
|
transaction abort!
|
|
|
|
rollback completed
|
|
|
|
abort: pretxnclose hook exited with status 1
|
|
|
|
[255]
|
|
|
|
|
2016-04-14 12:41:15 +03:00
|
|
|
Hook from untrusted hgrc are reported as failure
|
|
|
|
================================================
|
|
|
|
|
|
|
|
$ cat << EOF > $TESTTMP/untrusted.py
|
|
|
|
> from mercurial import scmutil, util
|
|
|
|
> def uisetup(ui):
|
|
|
|
> class untrustedui(ui.__class__):
|
|
|
|
> def _trusted(self, fp, f):
|
|
|
|
> if util.normpath(fp.name).endswith('untrusted/.hg/hgrc'):
|
|
|
|
> return False
|
|
|
|
> return super(untrustedui, self)._trusted(fp, f)
|
|
|
|
> ui.__class__ = untrustedui
|
|
|
|
> EOF
|
|
|
|
$ cat << EOF >> $HGRCPATH
|
|
|
|
> [extensions]
|
|
|
|
> untrusted=$TESTTMP/untrusted.py
|
|
|
|
> EOF
|
|
|
|
$ hg init untrusted
|
|
|
|
$ cd untrusted
|
|
|
|
|
|
|
|
Non-blocking hook
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
$ cat << EOF >> .hg/hgrc
|
|
|
|
> [hooks]
|
|
|
|
> txnclose.testing=echo txnclose hook called
|
|
|
|
> EOF
|
|
|
|
$ touch a && hg commit -Aqm a
|
2017-03-31 12:02:05 +03:00
|
|
|
warning: untrusted hook txnclose.testing not executed
|
2016-04-14 12:41:15 +03:00
|
|
|
$ hg log
|
|
|
|
changeset: 0:3903775176ed
|
|
|
|
tag: tip
|
|
|
|
user: test
|
|
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
summary: a
|
|
|
|
|
|
|
|
|
|
|
|
Non-blocking hook
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
$ cat << EOF >> .hg/hgrc
|
|
|
|
> [hooks]
|
|
|
|
> pretxnclose.testing=echo pre-txnclose hook called
|
|
|
|
> EOF
|
|
|
|
$ touch b && hg commit -Aqm a
|
|
|
|
transaction abort!
|
|
|
|
rollback completed
|
2017-03-31 12:02:05 +03:00
|
|
|
abort: untrusted hook pretxnclose.testing not executed
|
2016-04-14 12:41:15 +03:00
|
|
|
(see 'hg help config.trusted')
|
|
|
|
[255]
|
|
|
|
$ hg log
|
|
|
|
changeset: 0:3903775176ed
|
|
|
|
tag: tip
|
|
|
|
user: test
|
|
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
summary: a
|
|
|
|
|