##// 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 Some basic Unix syntax is supported for portability, including ``$VAR``
894 Some basic Unix syntax is supported for portability, including ``$VAR``
895 and ``${VAR}`` style variables. To use a literal ``$``, it must be
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 ``changegroup``
905 ``changegroup``
899 Run after a changegroup has been added via push, pull or unbundle. The ID of
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 v = stringutil.pprint(v)
139 v = stringutil.pprint(v)
140 env['HG_' + k.upper()] = v
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 ui.note(_("running hook %s: %s\n") % (name, cmd))
146 ui.note(_("running hook %s: %s\n") % (name, cmd))
145
147
@@ -181,9 +183,11 b' def _hookitems(ui, _untrusted=False):'
181 """return all hooks items ready to be sorted"""
183 """return all hooks items ready to be sorted"""
182 hooks = {}
184 hooks = {}
183 for name, cmd in ui.configitems('hooks', untrusted=_untrusted):
185 for name, cmd in ui.configitems('hooks', untrusted=_untrusted):
184 if not name.startswith('priority.'):
186 if name.startswith('priority.') or name.startswith('tonative.'):
185 priority = ui.configint('hooks', 'priority.%s' % name, 0)
187 continue
186 hooks[name] = (-priority, len(hooks), name, cmd)
188
189 priority = ui.configint('hooks', 'priority.%s' % name, 0)
190 hooks[name] = (-priority, len(hooks), name, cmd)
187 return hooks
191 return hooks
188
192
189 _redirect = False
193 _redirect = False
@@ -194,6 +194,7 b' delete a remote bookmark'
194 bundle2-input: part header size: 0
194 bundle2-input: part header size: 0
195 bundle2-input: end of bundle2 stream
195 bundle2-input: end of bundle2 stream
196 bundle2-input-bundle: 3 parts total
196 bundle2-input-bundle: 3 parts total
197 converting hook "txnclose-bookmark.test" to native (windows !)
197 running hook txnclose-bookmark.test: sh $TESTTMP/hook.sh
198 running hook txnclose-bookmark.test: sh $TESTTMP/hook.sh
198 test-hook-bookmark: W: 0000000000000000000000000000000000000000 ->
199 test-hook-bookmark: W: 0000000000000000000000000000000000000000 ->
199 bundle2-output-bundle: "HG20", 1 parts total
200 bundle2-output-bundle: "HG20", 1 parts total
@@ -308,6 +309,7 b' delete a remote bookmark'
308 bundle2-input: part header size: 0
309 bundle2-input: part header size: 0
309 bundle2-input: end of bundle2 stream
310 bundle2-input: end of bundle2 stream
310 bundle2-input-bundle: 3 parts total
311 bundle2-input-bundle: 3 parts total
312 converting hook "txnclose-bookmark.test" to native (windows !)
311 running hook txnclose-bookmark.test: sh $TESTTMP/hook.sh
313 running hook txnclose-bookmark.test: sh $TESTTMP/hook.sh
312 test-hook-bookmark: W: 0000000000000000000000000000000000000000 ->
314 test-hook-bookmark: W: 0000000000000000000000000000000000000000 ->
313 bundle2-output-bundle: "HG20", 0 parts total
315 bundle2-output-bundle: "HG20", 0 parts total
@@ -205,6 +205,7 b' at first, test saving last-message.txt'
205 a
205 a
206 committing manifest
206 committing manifest
207 committing changelog
207 committing changelog
208 converting hook "pretxncommit.test-saving-last-message" to native (windows !)
208 running hook pretxncommit.test-saving-last-message: false
209 running hook pretxncommit.test-saving-last-message: false
209 transaction abort!
210 transaction abort!
210 rollback completed
211 rollback completed
@@ -230,6 +231,7 b' at first, test saving last-message.txt'
230 a
231 a
231 committing manifest
232 committing manifest
232 committing changelog
233 committing changelog
234 converting hook "pretxncommit.test-saving-last-message" to native (windows !)
233 running hook pretxncommit.test-saving-last-message: false
235 running hook pretxncommit.test-saving-last-message: false
234 transaction abort!
236 transaction abort!
235 rollback completed
237 rollback completed
@@ -494,6 +494,7 b' Test unix -> windows style variable subs'
494 $ cat > $TESTTMP/tmp.hgrc <<'EOF'
494 $ cat > $TESTTMP/tmp.hgrc <<'EOF'
495 > [hooks]
495 > [hooks]
496 > pre-add = echo no variables
496 > pre-add = echo no variables
497 > tonative.pre-add = False
497 > post-add = echo ran $HG_ARGS, literal \$non-var, 'also $non-var', $HG_RESULT
498 > post-add = echo ran $HG_ARGS, literal \$non-var, 'also $non-var', $HG_RESULT
498 > EOF
499 > EOF
499
500
@@ -503,6 +504,7 b' TODO: Windows should output double quote'
503 running hook pre-add: echo no variables
504 running hook pre-add: echo no variables
504 no variables
505 no variables
505 adding amended.txt
506 adding amended.txt
507 converting hook "post-add" to native (windows !)
506 running hook post-add: echo ran %HG_ARGS%, literal $non-var, 'also $non-var', %HG_RESULT% (windows !)
508 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 !)
509 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 !)
510 ran add -v amended.txt, literal $non-var, 'also $non-var', 0 (windows !)
@@ -183,6 +183,7 b' Commit with several checks'
183 overwriting a expanding keywords
183 overwriting a expanding keywords
184 updating the branch cache
184 updating the branch cache
185 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
185 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
186 converting hook "commit.test" to native (windows !)
186 running hook commit.test: cp a hooktest
187 running hook commit.test: cp a hooktest
187 $ hg status
188 $ hg status
188 ? hooktest
189 ? hooktest
@@ -90,10 +90,13 b' expect success'
90 remote: adding a revisions
90 remote: adding a revisions
91 remote: added 1 changesets with 1 changes to 1 files
91 remote: added 1 changesets with 1 changes to 1 files
92 remote: updating the branch cache
92 remote: updating the branch cache
93 remote: converting hook "txnclose-phase.test" to native (windows !)
93 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
94 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
94 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
95 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
96 remote: converting hook "txnclose-phase.test" to native (windows !)
95 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
97 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
96 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
98 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
99 remote: converting hook "changegroup" to native (windows !)
97 remote: running hook changegroup: sh -c "printenv.py changegroup 0"
100 remote: running hook changegroup: sh -c "printenv.py changegroup 0"
98 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)
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 % serve errors
102 % serve errors
@@ -110,10 +113,13 b' expect success'
110 remote: adding a revisions
113 remote: adding a revisions
111 remote: added 1 changesets with 1 changes to 1 files
114 remote: added 1 changesets with 1 changes to 1 files
112 remote: updating the branch cache
115 remote: updating the branch cache
116 remote: converting hook "txnclose-phase.test" to native (windows !)
113 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
117 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
114 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
118 remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b: draft -> public
119 remote: converting hook "txnclose-phase.test" to native (windows !)
115 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
120 remote: running hook txnclose-phase.test: sh $TESTTMP/hook.sh
116 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
121 remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872: -> public
122 remote: converting hook "changegroup" to native (windows !)
117 remote: running hook changegroup: sh -c "printenv.py changegroup 0"
123 remote: running hook changegroup: sh -c "printenv.py changegroup 0"
118 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)
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 % serve errors
125 % serve errors
General Comments 0
You need to be logged in to leave comments. Login now