Mercurial > hg
view contrib/casesmash.py @ 29276:4dd530df4742
check-code: replace quoted characters correctly
169cb9e47f8e tried to detect '.. note::' more exactly. But
implementation of it seems not correct, because:
- fromc.find(c) returns -1 for other than "." and ":"
- tochr[-1] returns "q" for such characters, but
- expected result for them is "o"
This patch uses dict to manage replacement instead of replacing
str.find() by str.index(), for improvement/refactoring in subsequent
patches. Examination by fixedmap is placed just after examination for
' ' and '\n', because subsequent patch will integrate the latter into
the former.
This patch also changes regexp for 'string join across lines with no
space' rule, and adds detailed test for it, because 169cb9e47f8e did:
- make repquote() distinguish "." (as "p") and ":" (as "q") from
others (as "o"), but
- not change this regexp without any reason (in commit log, at
least), even though this regexp depends on what "o" means
This patch doesn't focuses on deciding whether "." and/or ":" should
be followed by whitespace or not in translatable messages.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 31 May 2016 20:58:10 +0900 |
parents | 42a7301fb4d5 |
children | 2372284d9457 |
line wrap: on
line source
from __future__ import absolute_import import __builtin__ import os from mercurial import ( util, ) def lowerwrap(scope, funcname): f = getattr(scope, funcname) def wrap(fname, *args, **kwargs): d, base = os.path.split(fname) try: files = os.listdir(d or '.') except OSError: 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) scope.__dict__[funcname] = wrap def normcase(path): return path.lower() 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')