##// END OF EJS Templates
phases: avoid N² behavior in `advanceboundary`...
phases: avoid N² behavior in `advanceboundary` We allowed duplicated entries in the deque, which each entry could potentially insert all its ancestors. So advancing boundary for the full repository would mean each revision would walk all its ancestors, resulting in O(N²) iteration. For repository of any decent size, N² is quickly insane. We introduce a simple set to avoid this and get back to reasonable performance.

File last commit:

r49730:6000f5b2 default
r52398:c9ceb4f6 6.7 stable
Show More
casesmash.py
40 lines | 895 B | text/x-python | PythonLexer
Pulkit Goyal
casesmash: use absolute_import
r28351 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')