Show More
@@ -886,6 +886,12 b' They contain the type of hook which trig' | |||||
886 | of the hook in the config, respectively. In the example above, this will |
|
886 | of the hook in the config, respectively. In the example above, this will | |
887 | be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``. |
|
887 | be ``$HG_HOOKTYPE=incoming`` and ``$HG_HOOKNAME=incoming.email``. | |
888 |
|
888 | |||
|
889 | .. container:: windows | |||
|
890 | ||||
|
891 | Some basic Unix syntax is supported for portability, including ``$VAR`` | |||
|
892 | and ``${VAR}`` style variables. To use a literal ``$``, it must be | |||
|
893 | escaped with a back slash or inside of a strong quote. | |||
|
894 | ||||
889 | ``changegroup`` |
|
895 | ``changegroup`` | |
890 | Run after a changegroup has been added via push, pull or unbundle. The ID of |
|
896 | Run after a changegroup has been added via push, pull or unbundle. The ID of | |
891 | the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``. |
|
897 | the first new changeset is in ``$HG_NODE`` and last is in ``$HG_NODE_LAST``. |
@@ -120,8 +120,6 b' def pythonhook(ui, repo, htype, hname, f' | |||||
120 | return r, False |
|
120 | return r, False | |
121 |
|
121 | |||
122 | def _exthook(ui, repo, htype, name, cmd, args, throw): |
|
122 | def _exthook(ui, repo, htype, name, cmd, args, throw): | |
123 | ui.note(_("running hook %s: %s\n") % (name, cmd)) |
|
|||
124 |
|
||||
125 | starttime = util.timer() |
|
123 | starttime = util.timer() | |
126 | env = {} |
|
124 | env = {} | |
127 |
|
125 | |||
@@ -141,6 +139,12 b' def _exthook(ui, repo, htype, name, cmd,' | |||||
141 | v = stringutil.pprint(v) |
|
139 | v = stringutil.pprint(v) | |
142 | env['HG_' + k.upper()] = v |
|
140 | env['HG_' + k.upper()] = v | |
143 |
|
141 | |||
|
142 | if pycompat.iswindows: | |||
|
143 | environ = procutil.shellenviron(env) | |||
|
144 | cmd = util.platform.shelltocmdexe(cmd, environ) | |||
|
145 | ||||
|
146 | ui.note(_("running hook %s: %s\n") % (name, cmd)) | |||
|
147 | ||||
144 | if repo: |
|
148 | if repo: | |
145 | cwd = repo.root |
|
149 | cwd = repo.root | |
146 | else: |
|
150 | else: |
@@ -478,14 +478,7 b' This is an excuse to test hook with hist' | |||||
478 | 1:199b6bb90248 b |
|
478 | 1:199b6bb90248 b | |
479 | 0:6c795aa153cb a |
|
479 | 0:6c795aa153cb a | |
480 |
|
480 | |||
481 | Setup the proper environment variable symbol for the platform, to be subbed |
|
481 | $ hg histedit 6c795aa153cb --config hooks.commit='echo commit $HG_NODE' --commands - 2>&1 << EOF | fixbundle | |
482 | into the hook command. |
|
|||
483 | #if windows |
|
|||
484 | $ NODE="%HG_NODE%" |
|
|||
485 | #else |
|
|||
486 | $ NODE="\$HG_NODE" |
|
|||
487 | #endif |
|
|||
488 | $ hg histedit 6c795aa153cb --config hooks.commit="echo commit $NODE" --commands - 2>&1 << EOF | fixbundle |
|
|||
489 | > pick 199b6bb90248 b |
|
482 | > pick 199b6bb90248 b | |
490 | > fold a1a953ffb4b0 c |
|
483 | > fold a1a953ffb4b0 c | |
491 | > pick 6c795aa153cb a |
|
484 | > pick 6c795aa153cb a | |
@@ -496,8 +489,24 b' into the hook command.' | |||||
496 | 1:9599899f62c0 a |
|
489 | 1:9599899f62c0 a | |
497 | 0:79b99e9c8e49 b |
|
490 | 0:79b99e9c8e49 b | |
498 |
|
491 | |||
|
492 | Test unix -> windows style variable substitution in external hooks. | |||
|
493 | ||||
|
494 | $ cat > $TESTTMP/tmp.hgrc <<'EOF' | |||
|
495 | > [hooks] | |||
|
496 | > pre-add = echo no variables | |||
|
497 | > post-add = echo ran $HG_ARGS, literal \$non-var, 'also $non-var', $HG_RESULT | |||
|
498 | > EOF | |||
|
499 | ||||
|
500 | TODO: Windows should output double quotes around "also $non-var" | |||
499 | $ echo "foo" > amended.txt |
|
501 | $ echo "foo" > amended.txt | |
500 | $ hg add amended.txt |
|
502 | $ HGRCPATH=$TESTTMP/tmp.hgrc hg add -v amended.txt | |
|
503 | running hook pre-add: echo no variables | |||
|
504 | no variables | |||
|
505 | adding amended.txt | |||
|
506 | running hook post-add: echo ran %HG_ARGS%, literal $non-var, 'also $non-var', %HG_RESULT% (windows !) | |||
|
507 | running hook post-add: echo ran $HG_ARGS, literal \$non-var, 'also $non-var', $HG_RESULT (no-windows !) | |||
|
508 | ran add -v amended.txt, literal $non-var, 'also $non-var', 0 (windows !) | |||
|
509 | ran add -v amended.txt, literal $non-var, also $non-var, 0 (no-windows !) | |||
501 | $ hg ci -q --config extensions.largefiles= --amend -I amended.txt |
|
510 | $ hg ci -q --config extensions.largefiles= --amend -I amended.txt | |
502 | The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !) |
|
511 | The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !) | |
503 |
|
512 |
@@ -333,12 +333,7 b' Test rebase interrupted by hooks' | |||||
333 |
|
333 | |||
334 | $ cp -R a3 hook-pretxncommit |
|
334 | $ cp -R a3 hook-pretxncommit | |
335 | $ cd hook-pretxncommit |
|
335 | $ cd hook-pretxncommit | |
336 | #if windows |
|
336 | $ hg rebase --source 2 --dest 5 --tool internal:other --config 'hooks.pretxncommit=hg log -r $HG_NODE | grep "summary: C"' | |
337 | $ NODE="%HG_NODE%" |
|
|||
338 | #else |
|
|||
339 | $ NODE="\$HG_NODE" |
|
|||
340 | #endif |
|
|||
341 | $ hg rebase --source 2 --dest 5 --tool internal:other --config "hooks.pretxncommit=hg log -r $NODE | grep \"summary: C\"" |
|
|||
342 | rebasing 2:965c486023db "C" |
|
337 | rebasing 2:965c486023db "C" | |
343 | summary: C |
|
338 | summary: C | |
344 | rebasing 6:a0b2430ebfb8 "F" (tip) |
|
339 | rebasing 6:a0b2430ebfb8 "F" (tip) |
General Comments 0
You need to be logged in to leave comments.
Login now