Show More
@@ -893,7 +893,8 b' be ``$HG_HOOKTYPE=incoming`` and ``$HG_H' | |||||
893 |
|
893 | |||
894 | Some basic Unix syntax can be enabled for portability, including ``$VAR`` |
|
894 | Some basic Unix syntax can be enabled 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. Strong quotes | |
|
897 | will be replaced by double quotes after processing. | |||
897 |
|
898 | |||
898 | This feature is enabled by adding a prefix of ``tonative.`` to the hook |
|
899 | This feature is enabled by adding a prefix of ``tonative.`` to the hook | |
899 | name on a new line, and setting it to ``True``. For example:: |
|
900 | name on a new line, and setting it to ``True``. For example:: |
@@ -268,7 +268,7 b' def shelltocmdexe(path, env):' | |||||
268 | 'cmd %var1% %var2% %var3% $missing ${missing} %missing%' |
|
268 | 'cmd %var1% %var2% %var3% $missing ${missing} %missing%' | |
269 | >>> # Single quote prevents expansion, as does \$ escaping |
|
269 | >>> # Single quote prevents expansion, as does \$ escaping | |
270 | >>> shelltocmdexe(b"cmd '$var1 ${var2} %var3%' \$var1 \${var2} \\", e) |
|
270 | >>> shelltocmdexe(b"cmd '$var1 ${var2} %var3%' \$var1 \${var2} \\", e) | |
271 |
|
|
271 | 'cmd "$var1 ${var2} %var3%" $var1 ${var2} \\' | |
272 | >>> # $$ is not special. %% is not special either, but can be the end and |
|
272 | >>> # $$ is not special. %% is not special either, but can be the end and | |
273 | >>> # start of consecutive variables |
|
273 | >>> # start of consecutive variables | |
274 | >>> shelltocmdexe(b"cmd $$ %% %var1%%var2%", e) |
|
274 | >>> shelltocmdexe(b"cmd $$ %% %var1%%var2%", e) | |
@@ -277,7 +277,7 b' def shelltocmdexe(path, env):' | |||||
277 | >>> shelltocmdexe(b"$var1 %var1%", {b'var1': b'%var2%', b'var2': b'boom'}) |
|
277 | >>> shelltocmdexe(b"$var1 %var1%", {b'var1': b'%var2%', b'var2': b'boom'}) | |
278 | '%var1% %var1%' |
|
278 | '%var1% %var1%' | |
279 | """ |
|
279 | """ | |
280 | if b'$' not in path: |
|
280 | if not any(c in path for c in b"$'"): | |
281 | return path |
|
281 | return path | |
282 |
|
282 | |||
283 | varchars = pycompat.sysbytes(string.ascii_letters + string.digits) + b'_-' |
|
283 | varchars = pycompat.sysbytes(string.ascii_letters + string.digits) + b'_-' | |
@@ -292,7 +292,7 b' def shelltocmdexe(path, env):' | |||||
292 | pathlen = len(path) |
|
292 | pathlen = len(path) | |
293 | try: |
|
293 | try: | |
294 | index = path.index(b'\'') |
|
294 | index = path.index(b'\'') | |
295 |
res += b' |
|
295 | res += b'"' + path[:index] + b'"' | |
296 | except ValueError: |
|
296 | except ValueError: | |
297 | res += c + path |
|
297 | res += c + path | |
298 | index = pathlen - 1 |
|
298 | index = pathlen - 1 |
@@ -499,16 +499,15 b' Test unix -> windows style variable subs' | |||||
499 | > tonative.post-add = True |
|
499 | > tonative.post-add = True | |
500 | > EOF |
|
500 | > EOF | |
501 |
|
501 | |||
502 | TODO: Windows should output double quotes around "also $non-var" |
|
|||
503 | $ echo "foo" > amended.txt |
|
502 | $ echo "foo" > amended.txt | |
504 | $ HGRCPATH=$TESTTMP/tmp.hgrc hg add -v amended.txt |
|
503 | $ HGRCPATH=$TESTTMP/tmp.hgrc hg add -v amended.txt | |
505 | running hook pre-add: echo no variables |
|
504 | running hook pre-add: echo no variables | |
506 | no variables |
|
505 | no variables | |
507 | adding amended.txt |
|
506 | adding amended.txt | |
508 | converting hook "post-add" to native (windows !) |
|
507 | converting hook "post-add" to native (windows !) | |
509 |
running hook post-add: echo ran %HG_ARGS%, literal $non-var, |
|
508 | running hook post-add: echo ran %HG_ARGS%, literal $non-var, "also $non-var", %HG_RESULT% (windows !) | |
510 | 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 !) | |
511 |
ran add -v amended.txt, literal $non-var, |
|
510 | ran add -v amended.txt, literal $non-var, "also $non-var", 0 (windows !) | |
512 | ran add -v amended.txt, literal $non-var, also $non-var, 0 (no-windows !) |
|
511 | ran add -v amended.txt, literal $non-var, also $non-var, 0 (no-windows !) | |
513 | $ hg ci -q --config extensions.largefiles= --amend -I amended.txt |
|
512 | $ hg ci -q --config extensions.largefiles= --amend -I amended.txt | |
514 | The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !) |
|
513 | The fsmonitor extension is incompatible with the largefiles extension and has been disabled. (fsmonitor !) |
General Comments 0
You need to be logged in to leave comments.
Login now