Mercurial > public > mercurial-scm > hg
comparison mercurial/profiling.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 | 517bc1cd7033 |
comparison
equal
deleted
inserted
replaced
30819:897726622877 | 30820:6a70cf94d1b5 |
---|---|
10 import contextlib | 10 import contextlib |
11 import time | 11 import time |
12 | 12 |
13 from .i18n import _ | 13 from .i18n import _ |
14 from . import ( | 14 from . import ( |
15 encoding, | |
15 error, | 16 error, |
16 pycompat, | |
17 util, | 17 util, |
18 ) | 18 ) |
19 | 19 |
20 @contextlib.contextmanager | 20 @contextlib.contextmanager |
21 def lsprofile(ui, fp): | 21 def lsprofile(ui, fp): |
118 """Start profiling. | 118 """Start profiling. |
119 | 119 |
120 Profiling is active when the context manager is active. When the context | 120 Profiling is active when the context manager is active. When the context |
121 manager exits, profiling results will be written to the configured output. | 121 manager exits, profiling results will be written to the configured output. |
122 """ | 122 """ |
123 profiler = pycompat.osgetenv('HGPROF') | 123 profiler = encoding.environ.get('HGPROF') |
124 if profiler is None: | 124 if profiler is None: |
125 profiler = ui.config('profiling', 'type', default='stat') | 125 profiler = ui.config('profiling', 'type', default='stat') |
126 if profiler not in ('ls', 'stat', 'flame'): | 126 if profiler not in ('ls', 'stat', 'flame'): |
127 ui.warn(_("unrecognized profiler '%s' - ignored\n") % profiler) | 127 ui.warn(_("unrecognized profiler '%s' - ignored\n") % profiler) |
128 profiler = 'stat' | 128 profiler = 'stat' |