Show More
@@ -68,7 +68,7 b' def systemrcpath():' | |||||
68 |
|
68 | |||
69 | def userrcpath(): |
|
69 | def userrcpath(): | |
70 | '''return os-specific hgrc search path to the user dir''' |
|
70 | '''return os-specific hgrc search path to the user dir''' | |
71 |
home = |
|
71 | home = _legacy_expanduser(b'~') | |
72 | path = [os.path.join(home, b'mercurial.ini'), os.path.join(home, b'.hgrc')] |
|
72 | path = [os.path.join(home, b'mercurial.ini'), os.path.join(home, b'.hgrc')] | |
73 | userprofile = encoding.environ.get(b'USERPROFILE') |
|
73 | userprofile = encoding.environ.get(b'USERPROFILE') | |
74 | if userprofile and userprofile != home: |
|
74 | if userprofile and userprofile != home: | |
@@ -77,5 +77,37 b' def userrcpath():' | |||||
77 | return path |
|
77 | return path | |
78 |
|
78 | |||
79 |
|
79 | |||
|
80 | def _legacy_expanduser(path): | |||
|
81 | """Expand ~ and ~user constructs in the pre 3.8 style""" | |||
|
82 | ||||
|
83 | # Python 3.8+ changed the expansion of '~' from HOME to USERPROFILE. See | |||
|
84 | # https://bugs.python.org/issue36264. It also seems to capitalize the drive | |||
|
85 | # letter, as though it was processed through os.path.realpath(). | |||
|
86 | if not path.startswith(b'~'): | |||
|
87 | return path | |||
|
88 | ||||
|
89 | i, n = 1, len(path) | |||
|
90 | while i < n and path[i] not in b'\\/': | |||
|
91 | i += 1 | |||
|
92 | ||||
|
93 | if b'HOME' in encoding.environ: | |||
|
94 | userhome = encoding.environ[b'HOME'] | |||
|
95 | elif b'USERPROFILE' in encoding.environ: | |||
|
96 | userhome = encoding.environ[b'USERPROFILE'] | |||
|
97 | elif b'HOMEPATH' not in encoding.environ: | |||
|
98 | return path | |||
|
99 | else: | |||
|
100 | try: | |||
|
101 | drive = encoding.environ[b'HOMEDRIVE'] | |||
|
102 | except KeyError: | |||
|
103 | drive = b'' | |||
|
104 | userhome = os.path.join(drive, encoding.environ[b'HOMEPATH']) | |||
|
105 | ||||
|
106 | if i != 1: # ~user | |||
|
107 | userhome = os.path.join(os.path.dirname(userhome), path[1:i]) | |||
|
108 | ||||
|
109 | return userhome + path[i:] | |||
|
110 | ||||
|
111 | ||||
80 | def termsize(ui): |
|
112 | def termsize(ui): | |
81 | return win32.termsize() |
|
113 | return win32.termsize() |
General Comments 0
You need to be logged in to leave comments.
Login now