comparison mercurial/encoding.py @ 39818:24e493ec2229

py3: rename pycompat.getcwd() to encoding.getcwd() (API) We need to avoid os.getcwdb() on Windows to avoid DeprecationWarnings, and we need encoding.strtolocal() to encode the result of os.getcwd().
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 21 Sep 2018 19:48:23 -0400
parents e7aa113b14f7
children fb628c048d64
comparison
equal deleted inserted replaced
39817:94c25f694ec3 39818:24e493ec2229
230 if not _nativeenviron: 230 if not _nativeenviron:
231 # now encoding and helper functions are available, recreate the environ 231 # now encoding and helper functions are available, recreate the environ
232 # dict to be exported to other modules 232 # dict to be exported to other modules
233 environ = dict((tolocal(k.encode(u'utf-8')), tolocal(v.encode(u'utf-8'))) 233 environ = dict((tolocal(k.encode(u'utf-8')), tolocal(v.encode(u'utf-8')))
234 for k, v in os.environ.items()) # re-exports 234 for k, v in os.environ.items()) # re-exports
235
236 if pycompat.ispy3:
237 # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which
238 # returns bytes.
239 getcwd = os.getcwdb # re-exports
240 else:
241 getcwd = os.getcwd # re-exports
235 242
236 # How to treat ambiguous-width characters. Set to 'wide' to treat as wide. 243 # How to treat ambiguous-width characters. Set to 'wide' to treat as wide.
237 _wide = _sysstr(environ.get("HGENCODINGAMBIGUOUS", "narrow") == "wide" 244 _wide = _sysstr(environ.get("HGENCODINGAMBIGUOUS", "narrow") == "wide"
238 and "WFA" or "WF") 245 and "WFA" or "WF")
239 246