Mercurial > hg
comparison contrib/hg-ssh @ 47620:724066f23e2d
hg-ssh: normalize the drive of the current working directory on windows
For some reason os.getcwd() can return either `c:` or `C:`. We normalize this to
`C:` and the like. This fix `test-ssh-bundle1.t` on windows.
Differential Revision: https://phab.mercurial-scm.org/D11042
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 09 Jul 2021 23:38:24 +0200 |
parents | c102b704edb5 |
children | 6000f5b25c9b |
comparison
equal
deleted
inserted
replaced
47619:f0fbe8f4faa6 | 47620:724066f23e2d |
---|---|
29 command="hg-ssh --read-only repos/*" | 29 command="hg-ssh --read-only repos/*" |
30 """ | 30 """ |
31 from __future__ import absolute_import | 31 from __future__ import absolute_import |
32 | 32 |
33 import os | 33 import os |
34 import re | |
34 import shlex | 35 import shlex |
35 import sys | 36 import sys |
36 | 37 |
37 # enable importing on demand to reduce startup time | 38 # enable importing on demand to reduce startup time |
38 import hgdemandimport | 39 import hgdemandimport |
49 def main(): | 50 def main(): |
50 # Prevent insertion/deletion of CRs | 51 # Prevent insertion/deletion of CRs |
51 dispatch.initstdio() | 52 dispatch.initstdio() |
52 | 53 |
53 cwd = os.getcwd() | 54 cwd = os.getcwd() |
55 if os.name == 'nt': | |
56 # os.getcwd() is inconsistent on the capitalization of the drive | |
57 # letter, so adjust it. see https://bugs.python.org/issue40368 | |
58 if re.match('^[a-z]:', cwd): | |
59 cwd = cwd[0:1].upper() + cwd[1:] | |
60 | |
54 readonly = False | 61 readonly = False |
55 args = sys.argv[1:] | 62 args = sys.argv[1:] |
56 while len(args): | 63 while len(args): |
57 if args[0] == '--read-only': | 64 if args[0] == '--read-only': |
58 readonly = True | 65 readonly = True |