sapling/tests/dummyssh
Johan Schuijt-Li 877d1315da treemanifest/remotenames: use write path for reads after push
Summary:
Treemanifest uses it's own fallbackpath for reads in all cases, but
particularly in the case of remotenames it should stay on the path that is
actively being used by the push. It is possible to have remotenames which are
mirrored and selected by query strings in the repo path. In this case it is
possible that the mirror is still out of date when reading back data from our
push. Ensure that when doing a push the remote server this is considered
'sticky' so that we read back from the remote we pushed to, rather then
determening the path ourselves.

To disable, please use:
  treemanifest.stickypushpath=False

Reviewed By: DurhamG, markbt, quark-zju

Differential Revision: D14165444

fbshipit-source-id: 75a53ffab895d87a4c52814f7887145c134868b5
2019-02-22 06:03:18 -08:00

70 lines
1.6 KiB
Python
Executable File

#!/usr/bin/env python
from __future__ import absolute_import
import shlex
import subprocess
import os
import sys
os.chdir(os.getenv('TESTTMP'))
def parse(cmd):
"""
matches hg-ssh-wrapper
"""
try:
return shlex.split(cmd)
except ValueError as e:
eprint('Illegal command "%s": %s\n' % (cmd, e))
sys.exit(255)
def parse_repo_path(path):
"""
matches hg-ssh-wrapper
"""
path = path.split("?")
if len(path) == 1:
repo = path[0]
marker = None
elif len(path) == 2:
repo = path[0]
marker = path[1]
else:
eprint("Illegal repo name: %s\n" % "?".join(path))
sys.exit(255)
return repo, marker
# 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("'", '"')
cmdargv = parse(hgcmd)
if cmdargv[:2] == ["hg", "-R"] and cmdargv[3:] == ["serve", "--stdio"]:
path, marker = parse_repo_path(cmdargv[2])
if marker == "read_copy":
path = path + "_copy"
cmdargv[2] = path
hgcmd = subprocess.list2cmdline(cmdargv)
r = os.system(hgcmd)
sys.exit(bool(r))