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