Show More
@@ -9,6 +9,7 b' from __future__ import absolute_import, ' | |||||
9 |
|
9 | |||
10 | import locale |
|
10 | import locale | |
11 | import os |
|
11 | import os | |
|
12 | import re | |||
12 | import unicodedata |
|
13 | import unicodedata | |
13 |
|
14 | |||
14 | from .pycompat import getattr |
|
15 | from .pycompat import getattr | |
@@ -352,6 +353,8 b' if not _nativeenviron:' | |||||
352 | environ[tolocal(k.encode('utf-8'))] = tolocal(v.encode('utf-8')) |
|
353 | environ[tolocal(k.encode('utf-8'))] = tolocal(v.encode('utf-8')) | |
353 |
|
354 | |||
354 |
|
355 | |||
|
356 | DRIVE_RE = re.compile(b'^[a-z]:') | |||
|
357 | ||||
355 | if pycompat.ispy3: |
|
358 | if pycompat.ispy3: | |
356 | # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which |
|
359 | # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which | |
357 | # returns bytes. |
|
360 | # returns bytes. | |
@@ -363,7 +366,21 b' if pycompat.ispy3:' | |||||
363 | # os.path.realpath(), which is used on ``repo.root``. Since those |
|
366 | # os.path.realpath(), which is used on ``repo.root``. Since those | |
364 | # strings are compared in various places as simple strings, also call |
|
367 | # strings are compared in various places as simple strings, also call | |
365 | # realpath here. See https://bugs.python.org/issue40368 |
|
368 | # realpath here. See https://bugs.python.org/issue40368 | |
366 | getcwd = lambda: strtolocal(os.path.realpath(os.getcwd())) # re-exports |
|
369 | # | |
|
370 | # However this is not reliable, so lets explicitly make this drive | |||
|
371 | # letter upper case. | |||
|
372 | # | |||
|
373 | # note: we should consider dropping realpath here since it seems to | |||
|
374 | # change the semantic of `getcwd`. | |||
|
375 | ||||
|
376 | def getcwd(): | |||
|
377 | cwd = os.getcwd() # re-exports | |||
|
378 | cwd = os.path.realpath(cwd) | |||
|
379 | cwd = strtolocal(cwd) | |||
|
380 | if DRIVE_RE.match(cwd): | |||
|
381 | cwd = cwd[0:1].upper() + cwd[1:] | |||
|
382 | return cwd | |||
|
383 | ||||
367 | else: |
|
384 | else: | |
368 | getcwd = os.getcwdb # re-exports |
|
385 | getcwd = os.getcwdb # re-exports | |
369 | else: |
|
386 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now