changeset 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 f0fbe8f4faa6
children d6ee6456bd5f
files contrib/hg-ssh
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/hg-ssh	Sat Jul 10 01:15:03 2021 +0200
+++ b/contrib/hg-ssh	Fri Jul 09 23:38:24 2021 +0200
@@ -31,6 +31,7 @@
 from __future__ import absolute_import
 
 import os
+import re
 import shlex
 import sys
 
@@ -51,6 +52,12 @@
     dispatch.initstdio()
 
     cwd = os.getcwd()
+    if os.name == 'nt':
+        # os.getcwd() is inconsistent on the capitalization of the drive
+        # letter, so adjust it. see https://bugs.python.org/issue40368
+        if re.match('^[a-z]:', cwd):
+            cwd = cwd[0:1].upper() + cwd[1:]
+
     readonly = False
     args = sys.argv[1:]
     while len(args):