sapling/tests/dummyssh
Aida Getoeva 93252b7fd2 Enable batch mode for SSH during background pushbackup
Summary:
Added passing BatchMode option to SSH call only when puchbackup runs in background.
Also fixed dummyssh in skipping options before hostname, added unittest.

Reviewed By: quark-zju

Differential Revision: D7119123

fbshipit-source-id: 2c8e66fee44cca5b23389cba8e21e3a0b237268e
2018-04-13 21:51:21 -07:00

32 lines
746 B
Python
Executable File

#!/usr/bin/env python
from __future__ import absolute_import
import os
import sys
os.chdir(os.getenv('TESTTMP'))
# Skipping SSH options
host_index = 1
while host_index < len(sys.argv) and sys.argv[host_index].startswith('-'):
host_index += 1
if sys.argv[host_index] != "user@dummy":
sys.exit(-1)
os.environ["SSH_CLIENT"] = "%s 1 2" % os.environ.get('LOCALIP', '127.0.0.1')
log = open("dummylog", "ab")
log.write("Got arguments")
for i, arg in enumerate(sys.argv[1:]):
log.write(" %d:%s" % (i + 1, arg))
log.write("\n")
log.close()
hgcmd = sys.argv[host_index + 1]
if os.name == 'nt':
# hack to make simple unix single quote quoting work on windows
hgcmd = hgcmd.replace("'", '"')
r = os.system(hgcmd)
sys.exit(bool(r))