Patchwork D11042: hg-ssh: normalize the drive of the current working directory on windows

login
register
mail settings
Submitter phabricator
Date July 10, 2021, 12:35 a.m.
Message ID <differential-rev-PHID-DREV-z7cqjhswmftql2omnqm2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49355/
State Superseded
Headers show

Comments

phabricator - July 10, 2021, 12:35 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11042

AFFECTED FILES
  contrib/hg-ssh

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/contrib/hg-ssh b/contrib/hg-ssh
--- a/contrib/hg-ssh
+++ b/contrib/hg-ssh
@@ -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.
+        if re.match('^[a-z]:', cwd):
+            cwd = cwd[0:1].upper() + cwd[1:]
+
     readonly = False
     args = sys.argv[1:]
     while len(args):