Mercurial > hg
diff mercurial/util.py @ 6839:01db3e101362
move filename encoding functions from util.py to new store.py
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Thu, 24 Jul 2008 16:32:51 +0200 |
parents | c016dc1a8e91 |
children | 11229144aa01 |
line wrap: on
line diff
--- a/mercurial/util.py Thu Jul 24 22:46:45 2008 +0200 +++ b/mercurial/util.py Thu Jul 24 16:32:51 2008 +0200 @@ -1345,39 +1345,6 @@ return name return find_in_path(name, os.environ.get('PATH', ''), default=default) -def _buildencodefun(): - e = '_' - win_reserved = [ord(x) for x in '\\:*?"<>|'] - cmap = dict([ (chr(x), chr(x)) for x in xrange(127) ]) - for x in (range(32) + range(126, 256) + win_reserved): - cmap[chr(x)] = "~%02x" % x - for x in range(ord("A"), ord("Z")+1) + [ord(e)]: - cmap[chr(x)] = e + chr(x).lower() - dmap = {} - for k, v in cmap.iteritems(): - dmap[v] = k - def decode(s): - i = 0 - while i < len(s): - for l in xrange(1, 4): - try: - yield dmap[s[i:i+l]] - i += l - break - except KeyError: - pass - else: - raise KeyError - return (lambda s: "".join([cmap[c] for c in s]), - lambda s: "".join(list(decode(s)))) - -encodefilename, decodefilename = _buildencodefun() - -def encodedopener(openerfn, fn): - def o(path, *args, **kw): - return openerfn(fn(path), *args, **kw) - return o - def mktempcopy(name, emptyok=False, createmode=None): """Create a temporary file with the same contents from name