diff hgext/largefiles/lfutil.py @ 30820:6a70cf94d1b5

py3: replace pycompat.getenv with encoding.environ.get pycompat.getenv returns os.getenvb on py3 which is not available on Windows. This patch replaces them with encoding.environ.get and checks to ensure no new instances of os.getenv or os.setenv are introduced.
author Pulkit Goyal <7895pulkit@gmail.com>
date Sun, 15 Jan 2017 13:17:05 +0530
parents 69acfd2ca11e
children 21fa3d3688f3
line wrap: on
line diff
--- a/hgext/largefiles/lfutil.py	Sun Jan 15 16:33:15 2017 +0900
+++ b/hgext/largefiles/lfutil.py	Sun Jan 15 13:17:05 2017 +0530
@@ -19,6 +19,7 @@
 
 from mercurial import (
     dirstate,
+    encoding,
     error,
     httpconnection,
     match as matchmod,
@@ -74,19 +75,19 @@
     if path:
         return path
     if pycompat.osname == 'nt':
-        appdata = pycompat.osgetenv('LOCALAPPDATA',\
-                        pycompat.osgetenv('APPDATA'))
+        appdata = encoding.environ.get('LOCALAPPDATA',\
+                        encoding.environ.get('APPDATA'))
         if appdata:
             return os.path.join(appdata, longname)
     elif platform.system() == 'Darwin':
-        home = pycompat.osgetenv('HOME')
+        home = encoding.environ.get('HOME')
         if home:
             return os.path.join(home, 'Library', 'Caches', longname)
     elif pycompat.osname == 'posix':
-        path = pycompat.osgetenv('XDG_CACHE_HOME')
+        path = encoding.environ.get('XDG_CACHE_HOME')
         if path:
             return os.path.join(path, longname)
-        home = pycompat.osgetenv('HOME')
+        home = encoding.environ.get('HOME')
         if home:
             return os.path.join(home, '.cache', longname)
     else: