Skip to content

Commit b3fd513

Browse files
quark-zjufacebook-github-bot
authored andcommitted
util: make gethgcmd more reliable
Summary: It uses `sys.argv`, which might be rewritten by `debugshell`. Capture `sys.argv` to make hgcmd more reliable. Reviewed By: DurhamG Differential Revision: D22993215 fbshipit-source-id: 5fa319e8023b656c6cdf96cb3229ea9f2c9b9b99
1 parent 3331771 commit b3fd513

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

eden/scm/edenscm/mercurial/posix.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,9 @@ def normcase(path):
663663

664664
try:
665665
bytepath = pycompat.encodeutf8(path)
666-
return pycompat.decodeutf8(encoding.asciilower(bytepath)) # exception for non-ASCII
666+
return pycompat.decodeutf8(
667+
encoding.asciilower(bytepath)
668+
) # exception for non-ASCII
667669
except UnicodeDecodeError:
668670
return normcasefallback(path)
669671

@@ -908,8 +910,8 @@ def spawndetached(args):
908910
return os.spawnvp(os.P_NOWAIT | getattr(os, "P_DETACH", 0), args[0], args)
909911

910912

911-
def gethgcmd():
912-
return sys.argv[:1]
913+
def gethgcmd(argv=sys.argv):
914+
return argv[:1]
913915

914916

915917
def makedir(path, notindexed):

eden/scm/edenscm/mercurial/windows.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ def syncdir(dirpath):
505505
# Do nothing.
506506

507507

508-
def gethgcmd():
509-
return [sys.executable] + sys.argv[:1]
508+
def gethgcmd(argv=sys.argv):
509+
return [sys.executable] + argv[:1]
510510

511511

512512
def groupmembers(name):

0 commit comments

Comments
 (0)