##// END OF EJS Templates
hook: add support for disabling the shell to native command translation...
Matt Harbison -
r38648:38dfd308 default
parent child Browse files
Show More
@@ -893,7 +893,14 b' be ``$HG_HOOKTYPE=incoming`` and ``$HG_H'
893 893
894 894 Some basic Unix syntax is supported for portability, including ``$VAR``
895 895 and ``${VAR}`` style variables. To use a literal ``$``, it must be
896 escaped with a back slash or inside of a strong quote.
896 escaped with a back slash or inside of a strong quote. This can be
897 disabled by adding a prefix of ``tonative.`` to the hook name on a new
898 line, and setting it to ``False``. For example::
899
900 [hooks]
901 incoming.autobuild = /my/build/hook
902 # disable translation to cmd.exe syntax for autobuild hook
903 tonative.incoming.autobuild = False
897 904
898 905 ``changegroup``
899 906 Run after a changegroup has been added via push, pull or unbundle. The ID of
@@ -139,7 +139,9 b' def _exthook(ui, repo, htype, name, cmd,'
139 139 v = stringutil.pprint(v)
140 140 env['HG_' + k.upper()] = v
141 141
142 cmd = procutil.shelltonative(cmd, env)
142 if ui.configbool('hooks', 'tonative.%s' % name, pycompat.iswindows):
143 ui.note(_('converting hook "%s" to native\n') % name)
144 cmd = procutil.shelltonative(cmd, env)
143 145
144 146 ui.note(_("running hook %s: %s\n") % (name, cmd))
145 147
@@ -181,9 +183,11 b' def _hookitems(ui, _untrusted=False):'
181 183 """return all hooks items ready to be sorted"""
182 184 hooks = {}
183 185 for name, cmd in ui.configitems('hooks', untrusted=_untrusted):
184 if not name.startswith('priority.'):
185 priority = ui.configint('hooks', 'priority.%s' % name, 0)
186 hooks[name] = (-priority, len(hooks), name, cmd)
186 if name.startswith('priority.') or name.startswith('tonative.'):
187 continue
188
189 priority = ui.configint('hooks', 'priority.%s' % name, 0)
190 hooks[name] = (-priority, len(hooks), name, cmd)
187 191 return hooks
188 192
189 193 _redirect = False
@@ -194,6 +194,7 b' delete a remote bookmark'
194 194 bundle2-input: part header size: 0
195 195 bundle2-input: end of bundle2 stream
196 196 bundle2-input-bundle: 3 parts total
197 converting hook "txnclose-bookmark.test" to native (windows !)
197 198 running hook txnclose-bookmark.test: sh $TESTTMP/hook.sh
198 199 test-hook-bookmark: W: 0000000000000000000000000000000000000000 ->
199 200 bundle2-output-bundle: "HG20", 1 parts total
@@ -308,6 +309,7 b' delete a remote bookmark'
308 309 bundle2-input: part header size: 0
309 310 bundle2-input: end of bundle2 stream
310 311 bundle2-input-bundle: 3 parts total
312 converting hook "txnclose-bookmark.test" to native (windows !)
311 313 running hook txnclose-bookmark.test: sh $TESTTMP/hook.sh
312 314 test-hook-bookmark: W: 0000000000000000000000000000000000000000 ->
313 315 bundle2-output-bundle: "HG20", 0 parts total
@@ -205,6 +205,7 b' at first, test saving last-message.txt'
205 205 a
206 206 committing manifest
207 207 committing changelog
208 converting hook "pretxncommit.test-saving-last-message" to native (windows !)
208 209 running hook pretxncommit.test-saving-last-message: false
209 210 transaction abort!
210 211 rollback completed
@@ -230,6 +231,7 b' at first, test saving last-message.txt'
230 231 a
231 232 committing manifest
232 233 committing changelog
234 converting hook "pretxncommit.test-saving-last-message" to native (windows !)
233 235 running hook pretxncommit.test-saving-last-message: false
234 236 transaction abort!
235 237 rollback completed
@@ -494,6 +494,7 b' Test unix -> windows style variable subs'
494 494 $ cat > $TESTTMP/tmp.hgrc <<'EOF'
495 495 > [hooks]
496 496 > pre-add = echo no variables
497 > tonative.pre-add = False
497 498 > post-add = echo ran $HG_ARGS, literal \$non-var, 'also $non-var', $HG_RESULT
498 499 > EOF
499 500
@@ -503,6 +504,7 b' TODO: Windows should output double quote'
503 504 running hook pre-add: echo no variables
504 505 no variables
505 506 adding amended.txt
507 converting hook "post-add" to native (windows !)
506 508 running hook post-add: echo ran %HG_ARGS%, literal $non-var, 'also $non-var', %HG_RESULT% (windows !)
507 509 running hook post-add: echo ran $HG_ARGS, literal \$non-var, 'also $non-var', $HG_RESULT (no-windows !)
508 510 ran add -v amended.txt, literal $non-var, 'also $non-var', 0 (windows !)
@@ -183,6 +183,7 b' Commit with several checks'
183 183 overwriting a expanding keywords
184 184 updating the branch cache
185 185 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
186 converting hook "commit.test" to native (windows !)
186 187 running hook commit.test: cp a hooktest
187 188 $ hg status
188 189 ? hooktest
@@ -90,10 +90,13 b' expect success'
90 90 remote: adding a revisions
91 91 remote: added 1 changesets with 1 changes to 1 files
92 92 remote: updating the branch cache
93 remote: converting hook "txnclose-phase.test" to native (windows !)
93 94 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
94 95 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
96 remote: converting hook "txnclose-phase.test" to native (windows !)
95 97 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
96 98 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
99 remote: converting hook "changegroup" to native (windows !)
97 100 remote: running hook changegroup: sh -c "printenv.py changegroup 0"
98 101 remote: changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
99 102 % serve errors
@@ -110,10 +113,13 b' expect success'
110 113 remote: adding a revisions
111 114 remote: added 1 changesets with 1 changes to 1 files
112 115 remote: updating the branch cache
116 remote: converting hook "txnclose-phase.test" to native (windows !)
113 117 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
114 118 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
119 remote: converting hook "txnclose-phase.test" to native (windows !)
115 120 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
116 121 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
122 remote: converting hook "changegroup" to native (windows !)
117 123 remote: running hook changegroup: sh -c "printenv.py changegroup 0"
118 124 remote: changegroup hook: HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
119 125 % serve errors
General Comments 0
You need to be logged in to leave comments. Login now