##// END OF EJS Templates
tests: collapse some more trivial if PYTHON3 blocks...
tests: collapse some more trivial if PYTHON3 blocks This doesn't account for all of the references to PYTHON3. But it accounts for the ones that are more trivial and don't entail logical changes. Differential Revision: https://phab.mercurial-scm.org/D12235

File last commit:

r43346:2372284d default
r49712:41c552a2 default
Show More
casesmash.py
41 lines | 934 B | text/x-python | PythonLexer
Pulkit Goyal
casesmash: use absolute_import
r28351 from __future__ import absolute_import
import __builtin__
import os
Augie Fackler
formatting: blacken the codebase...
r43346 from mercurial import util
Matt Mackall
merge with stable
r14730
def lowerwrap(scope, funcname):
f = getattr(scope, funcname)
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Mackall
merge with stable
r14730 def wrap(fname, *args, **kwargs):
d, base = os.path.split(fname)
try:
files = os.listdir(d or '.')
Simon Heimberg
cleanup: drop unused variables and an unused import
r19378 except OSError:
Matt Mackall
merge with stable
r14730 files = []
if base in files:
return f(fname, *args, **kwargs)
for fn in files:
if fn.lower() == base.lower():
return f(os.path.join(d, fn), *args, **kwargs)
return f(fname, *args, **kwargs)
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Mackall
merge with stable
r14730 scope.__dict__[funcname] = wrap
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Mackall
merge with stable
r14730 def normcase(path):
return path.lower()
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Mackall
merge with stable
r14730 os.path.normcase = normcase
for f in 'file open'.split():
lowerwrap(__builtin__, f)
for f in "chmod chown open lstat stat remove unlink".split():
lowerwrap(os, f)
for f in "exists lexists".split():
lowerwrap(os.path, f)
lowerwrap(util, 'posixfile')