changeset 30640:a150173da1c1

py3: replace os.environ with encoding.environ (part 2 of 5)
author Pulkit Goyal <7895pulkit@gmail.com>
date Sun, 18 Dec 2016 01:46:39 +0530
parents ad15646dc61c
children f1c9fafcbf46
files hgext/pager.py hgext/patchbomb.py mercurial/chgserver.py mercurial/sshserver.py mercurial/subrepo.py mercurial/worker.py
diffstat 6 files changed, 22 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/pager.py	Sun Dec 18 01:34:41 2016 +0530
+++ b/hgext/pager.py	Sun Dec 18 01:46:39 2016 +0530
@@ -71,6 +71,7 @@
     cmdutil,
     commands,
     dispatch,
+    encoding,
     extensions,
     util,
     )
@@ -123,7 +124,7 @@
         return
 
     def pagecmd(orig, ui, options, cmd, cmdfunc):
-        p = ui.config("pager", "pager", os.environ.get("PAGER"))
+        p = ui.config("pager", "pager", encoding.environ.get("PAGER"))
         usepager = False
         always = util.parsebool(options['pager'])
         auto = options['pager'] == 'auto'
--- a/hgext/patchbomb.py	Sun Dec 18 01:34:41 2016 +0530
+++ b/hgext/patchbomb.py	Sun Dec 18 01:46:39 2016 +0530
@@ -75,6 +75,7 @@
 from mercurial import (
     cmdutil,
     commands,
+    encoding,
     error,
     hg,
     mail,
@@ -693,8 +694,8 @@
         if opts.get('test'):
             ui.status(_('displaying '), subj, ' ...\n')
             ui.flush()
-            if 'PAGER' in os.environ and not ui.plain():
-                fp = util.popen(os.environ['PAGER'], 'w')
+            if 'PAGER' in encoding.environ and not ui.plain():
+                fp = util.popen(encoding.environ['PAGER'], 'w')
             else:
                 fp = ui
             generator = emailmod.Generator.Generator(fp, mangle_from_=False)
--- a/mercurial/chgserver.py	Sun Dec 18 01:34:41 2016 +0530
+++ b/mercurial/chgserver.py	Sun Dec 18 01:46:39 2016 +0530
@@ -55,6 +55,7 @@
 from . import (
     cmdutil,
     commandserver,
+    encoding,
     error,
     extensions,
     osutil,
@@ -102,7 +103,8 @@
     for section in _configsections:
         sectionitems.append(ui.configitems(section))
     sectionhash = _hashlist(sectionitems)
-    envitems = [(k, v) for k, v in os.environ.iteritems() if _envre.match(k)]
+    envitems = [(k, v) for k, v in encoding.environ.iteritems()
+                if _envre.match(k)]
     envhash = _hashlist(sorted(envitems))
     return sectionhash[:6] + envhash[:6]
 
@@ -177,7 +179,7 @@
     if not ui.formatted():
         return
 
-    p = ui.config("pager", "pager", os.environ.get("PAGER"))
+    p = ui.config("pager", "pager", encoding.environ.get("PAGER"))
     usepager = False
     always = util.parsebool(options['pager'])
     auto = options['pager'] == 'auto'
@@ -237,7 +239,7 @@
                 if val is True:
                     return '1'
                 return str(val)
-            env = os.environ.copy()
+            env = encoding.environ.copy()
             if environ:
                 env.update((k, py2shell(v)) for k, v in environ.iteritems())
             env['HG'] = util.hgexecutable()
@@ -512,8 +514,8 @@
         except ValueError:
             raise ValueError('unexpected value in setenv request')
         _log('setenv: %r\n' % sorted(newenv.keys()))
-        os.environ.clear()
-        os.environ.update(newenv)
+        encoding.environ.clear()
+        encoding.environ.update(newenv)
 
     capabilities = commandserver.server.capabilities.copy()
     capabilities.update({'attachio': attachio,
@@ -628,8 +630,8 @@
 def chgunixservice(ui, repo, opts):
     # CHGINTERNALMARK is temporarily set by chg client to detect if chg will
     # start another chg. drop it to avoid possible side effects.
-    if 'CHGINTERNALMARK' in os.environ:
-        del os.environ['CHGINTERNALMARK']
+    if 'CHGINTERNALMARK' in encoding.environ:
+        del encoding.environ['CHGINTERNALMARK']
 
     if repo:
         # one chgserver can serve multiple repos. drop repo information
--- a/mercurial/sshserver.py	Sun Dec 18 01:34:41 2016 +0530
+++ b/mercurial/sshserver.py	Sun Dec 18 01:46:39 2016 +0530
@@ -8,11 +8,11 @@
 
 from __future__ import absolute_import
 
-import os
 import sys
 
 from .i18n import _
 from . import (
+    encoding,
     error,
     hook,
     util,
@@ -131,5 +131,5 @@
         return cmd != ''
 
     def _client(self):
-        client = os.environ.get('SSH_CLIENT', '').split(' ', 1)[0]
+        client = encoding.environ.get('SSH_CLIENT', '').split(' ', 1)[0]
         return 'remote:ssh:' + client
--- a/mercurial/subrepo.py	Sun Dec 18 01:34:41 2016 +0530
+++ b/mercurial/subrepo.py	Sun Dec 18 01:46:39 2016 +0530
@@ -24,6 +24,7 @@
 from . import (
     cmdutil,
     config,
+    encoding,
     error,
     exchange,
     filemerge,
@@ -1102,7 +1103,7 @@
             path = self.wvfs.reljoin(self._ctx.repo().origroot,
                                      self._path, filename)
             cmd.append(path)
-        env = dict(os.environ)
+        env = dict(encoding.environ)
         # Avoid localized output, preserve current locale for everything else.
         lc_all = env.get('LC_ALL')
         if lc_all:
@@ -1398,7 +1399,7 @@
         """
         self.ui.debug('%s: git %s\n' % (self._relpath, ' '.join(commands)))
         if env is None:
-            env = os.environ.copy()
+            env = encoding.environ.copy()
         # disable localization for Git output (issue5176)
         env['LC_ALL'] = 'C'
         # fix for Git CVE-2015-7545
@@ -1633,7 +1634,7 @@
         if self._gitmissing():
             raise error.Abort(_("subrepo %s is missing") % self._relpath)
         cmd = ['commit', '-a', '-m', text]
-        env = os.environ.copy()
+        env = encoding.environ.copy()
         if user:
             cmd += ['--author', user]
         if date:
--- a/mercurial/worker.py	Sun Dec 18 01:34:41 2016 +0530
+++ b/mercurial/worker.py	Sun Dec 18 01:46:39 2016 +0530
@@ -14,6 +14,7 @@
 
 from .i18n import _
 from . import (
+    encoding,
     error,
     scmutil,
     util,
@@ -32,7 +33,7 @@
 
     # windows
     try:
-        n = int(os.environ['NUMBER_OF_PROCESSORS'])
+        n = int(encoding.environ['NUMBER_OF_PROCESSORS'])
         if n > 0:
             return n
     except (KeyError, ValueError):