163 printf("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr) |
163 printf("stderr from '%s':" % (' '.join(cmd)), file=sys.stderr) |
164 printf(b'\n'.join([b' ' + e for e in err]), file=sys.stderr) |
164 printf(b'\n'.join([b' ' + e for e in err]), file=sys.stderr) |
165 return '' |
165 return '' |
166 return out |
166 return out |
167 |
167 |
|
168 |
|
169 def gethgenv(): |
|
170 # Execute hg out of this directory with a custom environment which takes |
|
171 # care to not use any hgrc files and do no localization. |
|
172 env = {'HGMODULEPOLICY': 'py', |
|
173 'HGRCPATH': '', |
|
174 'LANGUAGE': 'C', |
|
175 'PATH': ''} # make pypi modules that use os.environ['PATH'] happy |
|
176 if 'LD_LIBRARY_PATH' in os.environ: |
|
177 env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] |
|
178 if 'SystemRoot' in os.environ: |
|
179 # SystemRoot is required by Windows to load various DLLs. See: |
|
180 # https://bugs.python.org/issue13524#msg148850 |
|
181 env['SystemRoot'] = os.environ['SystemRoot'] |
|
182 |
|
183 env = gethgenv() |
168 version = '' |
184 version = '' |
169 |
|
170 # Execute hg out of this directory with a custom environment which takes care |
|
171 # to not use any hgrc files and do no localization. |
|
172 env = {'HGMODULEPOLICY': 'py', |
|
173 'HGRCPATH': '', |
|
174 'LANGUAGE': 'C', |
|
175 'PATH': ''} # make pypi modules that use os.environ['PATH'] happy |
|
176 if 'LD_LIBRARY_PATH' in os.environ: |
|
177 env['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] |
|
178 if 'SystemRoot' in os.environ: |
|
179 # SystemRoot is required by Windows to load various DLLs. See: |
|
180 # https://bugs.python.org/issue13524#msg148850 |
|
181 env['SystemRoot'] = os.environ['SystemRoot'] |
|
182 |
185 |
183 if os.path.isdir('.hg'): |
186 if os.path.isdir('.hg'): |
184 cmd = [sys.executable, 'hg', 'log', '-r', '.', '--template', '{tags}\n'] |
187 cmd = [sys.executable, 'hg', 'log', '-r', '.', '--template', '{tags}\n'] |
185 numerictags = [t for t in runhg(cmd, env).split() if t[0:1].isdigit()] |
188 numerictags = [t for t in runhg(cmd, env).split() if t[0:1].isdigit()] |
186 hgid = runhg([sys.executable, 'hg', 'id', '-i'], env).strip() |
189 hgid = runhg([sys.executable, 'hg', 'id', '-i'], env).strip() |