Show More
@@ -892,9 +892,11 b' be ``$HG_HOOKTYPE=incoming`` and ``$HG_H' | |||||
892 | .. container:: windows |
|
892 | .. container:: windows | |
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. |
|
895 | and ``${VAR}`` style variables. A ``~`` followed by ``\`` or ``/`` will | |
896 | escaped with a back slash or inside of a strong quote. Strong quotes |
|
896 | be expanded to ``%USERPROFILE%`` to simulate a subset of tilde expansion | |
897 | will be replaced by double quotes after processing. |
|
897 | on Unix. To use a literal ``$`` or ``~``, it must be escaped with a back | |
|
898 | slash or inside of a strong quote. Strong quotes will be replaced by | |||
|
899 | double quotes after processing. | |||
898 |
|
900 | |||
899 | This feature is enabled by adding a prefix of ``tonative.`` to the hook |
|
901 | This feature is enabled by adding a prefix of ``tonative.`` to the hook | |
900 | name on a new line, and setting it to ``True``. For example:: |
|
902 | name on a new line, and setting it to ``True``. For example:: |
@@ -276,8 +276,11 b' def shelltocmdexe(path, env):' | |||||
276 | >>> # No double substitution |
|
276 | >>> # No double substitution | |
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 | >>> # Tilde expansion | |||
|
280 | >>> shelltocmdexe(b"~/dir ~\dir2 ~tmpfile \~/", {}) | |||
|
281 | '%USERPROFILE%/dir %USERPROFILE%\\dir2 ~tmpfile ~/' | |||
279 | """ |
|
282 | """ | |
280 | if not any(c in path for c in b"$'"): |
|
283 | if not any(c in path for c in b"$'~"): | |
281 | return path |
|
284 | return path | |
282 |
|
285 | |||
283 | varchars = pycompat.sysbytes(string.ascii_letters + string.digits) + b'_-' |
|
286 | varchars = pycompat.sysbytes(string.ascii_letters + string.digits) + b'_-' | |
@@ -344,9 +347,13 b' def shelltocmdexe(path, env):' | |||||
344 |
|
347 | |||
345 | if c != '': |
|
348 | if c != '': | |
346 | index -= 1 |
|
349 | index -= 1 | |
347 |
elif c == b' |
|
350 | elif (c == b'~' and index + 1 < pathlen | |
348 | # Skip '\', but only if it is escaping $ |
|
351 | and path[index + 1] in (b'\\', b'/')): | |
349 |
res += |
|
352 | res += "%USERPROFILE%" | |
|
353 | elif (c == b'\\' and index + 1 < pathlen | |||
|
354 | and path[index + 1] in (b'$', b'~')): | |||
|
355 | # Skip '\', but only if it is escaping $ or ~ | |||
|
356 | res += path[index + 1] | |||
350 | index += 1 |
|
357 | index += 1 | |
351 | else: |
|
358 | else: | |
352 | res += c |
|
359 | res += c |
General Comments 0
You need to be logged in to leave comments.
Login now