tests/dummyssh
author Martin von Zweigbergk <martinvonz@google.com>
Mon, 18 Apr 2022 20:45:38 -0700
branchstable
changeset 48841 770e1352e9f9
parent 47773 fb8389f227a0
child 48966 6000f5b25c9b
permissions -rwxr-xr-x
amend: don't remove unselected removals from memctx When there are removed files in the working copy and they are not selected to be amended into the parent, the `filectxfn` we create for the `memctx` would still return `None` before this patch. That's clearly incorrect; we should return the `filectx` from the unamended commit. Somehow it seems to not matter much except for the case with copies stored in changesets. Thanks to Kyle Lippincott for doing all the debugging and identifying the fix for this issue. Differential Revision: https://phab.mercurial-scm.org/D12573
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45849
c102b704edb5 global: use python3 in shebangs
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36159
diff changeset
     1
#!/usr/bin/env python3
14186
8513bd2e7259 tests: share dummyssh
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
     2
29159
26d4ce8ca2bd py3: make tests/dummyssh use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 19320
diff changeset
     3
from __future__ import absolute_import
26d4ce8ca2bd py3: make tests/dummyssh use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 19320
diff changeset
     4
26d4ce8ca2bd py3: make tests/dummyssh use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents: 19320
diff changeset
     5
import os
47641
5d9f89cd4984 dummyssh: call python script with python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47640
diff changeset
     6
import shlex
47640
119673fb37aa dummyssh: use subprocess instead of os.call
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45849
diff changeset
     7
import subprocess
14186
8513bd2e7259 tests: share dummyssh
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
     8
import sys
8513bd2e7259 tests: share dummyssh
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
     9
8513bd2e7259 tests: share dummyssh
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    10
os.chdir(os.getenv('TESTTMP'))
8513bd2e7259 tests: share dummyssh
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    11
8513bd2e7259 tests: share dummyssh
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    12
if sys.argv[1] != "user@dummy":
8513bd2e7259 tests: share dummyssh
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    13
    sys.exit(-1)
8513bd2e7259 tests: share dummyssh
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    14
31027
bfdb0741f9f2 dummyssh: use LOCALIP
Jun Wu <quark@fb.com>
parents: 29159
diff changeset
    15
os.environ["SSH_CLIENT"] = "%s 1 2" % os.environ.get('LOCALIP', '127.0.0.1')
14186
8513bd2e7259 tests: share dummyssh
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    16
8513bd2e7259 tests: share dummyssh
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    17
log = open("dummylog", "ab")
35570
3e3f4c03876b tests: add b'' to string literals where bytes are required
Pulkit Goyal <7895pulkit@gmail.com>
parents: 31027
diff changeset
    18
log.write(b"Got arguments")
14186
8513bd2e7259 tests: share dummyssh
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    19
for i, arg in enumerate(sys.argv[1:]):
36159
3a763d7f40e1 py3: make dummyssh compatible with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35570
diff changeset
    20
    log.write(b" %d:%s" % (i + 1, arg.encode('latin1')))
3a763d7f40e1 py3: make dummyssh compatible with Python 3
Gregory Szorc <gregory.szorc@gmail.com>
parents: 35570
diff changeset
    21
log.write(b"\n")
14186
8513bd2e7259 tests: share dummyssh
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    22
log.close()
15768
cdf9c43445df tests: make simple single quotes work with dummyssh on windows
Mads Kiilerich <mads@kiilerich.com>
parents: 14186
diff changeset
    23
hgcmd = sys.argv[2]
cdf9c43445df tests: make simple single quotes work with dummyssh on windows
Mads Kiilerich <mads@kiilerich.com>
parents: 14186
diff changeset
    24
if os.name == 'nt':
cdf9c43445df tests: make simple single quotes work with dummyssh on windows
Mads Kiilerich <mads@kiilerich.com>
parents: 14186
diff changeset
    25
    # hack to make simple unix single quote quoting work on windows
cdf9c43445df tests: make simple single quotes work with dummyssh on windows
Mads Kiilerich <mads@kiilerich.com>
parents: 14186
diff changeset
    26
    hgcmd = hgcmd.replace("'", '"')
47641
5d9f89cd4984 dummyssh: call python script with python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47640
diff changeset
    27
    cmds = shlex.split(hgcmd)
5d9f89cd4984 dummyssh: call python script with python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47640
diff changeset
    28
    if cmds[0].endswith('.py'):
5d9f89cd4984 dummyssh: call python script with python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47640
diff changeset
    29
        python_exe = os.environ['PYTHON']
5d9f89cd4984 dummyssh: call python script with python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47640
diff changeset
    30
        cmds.insert(0, python_exe)
5d9f89cd4984 dummyssh: call python script with python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47640
diff changeset
    31
    hgcmd = shlex.join(cmds)
5d9f89cd4984 dummyssh: call python script with python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47640
diff changeset
    32
    # shlex generate windows incompatible string...
5d9f89cd4984 dummyssh: call python script with python
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47640
diff changeset
    33
    hgcmd = hgcmd.replace("'", '"')
47773
fb8389f227a0 dummyssh: make sure we don't inherit files descriptor to the children
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47641
diff changeset
    34
r = subprocess.call(hgcmd, shell=True, close_fds=True)
14186
8513bd2e7259 tests: share dummyssh
Mads Kiilerich <mads@kiilerich.com>
parents:
diff changeset
    35
sys.exit(bool(r))