comparison mercurial/store.py @ 10282:08a0f04b56bd

many, many trivial check-code fixups
author Matt Mackall <mpm@selenic.com>
date Mon, 25 Jan 2010 00:05:27 -0600
parents 25e572394f5c
children 23e608f42f2c
comparison
equal deleted inserted replaced
10281:e7d3b509af8b 10282:08a0f04b56bd
30 .replace(".hg.hg/", ".hg/")) 30 .replace(".hg.hg/", ".hg/"))
31 31
32 def _buildencodefun(): 32 def _buildencodefun():
33 e = '_' 33 e = '_'
34 win_reserved = [ord(x) for x in '\\:*?"<>|'] 34 win_reserved = [ord(x) for x in '\\:*?"<>|']
35 cmap = dict([ (chr(x), chr(x)) for x in xrange(127) ]) 35 cmap = dict([(chr(x), chr(x)) for x in xrange(127)])
36 for x in (range(32) + range(126, 256) + win_reserved): 36 for x in (range(32) + range(126, 256) + win_reserved):
37 cmap[chr(x)] = "~%02x" % x 37 cmap[chr(x)] = "~%02x" % x
38 for x in range(ord("A"), ord("Z")+1) + [ord(e)]: 38 for x in range(ord("A"), ord("Z")+1) + [ord(e)]:
39 cmap[chr(x)] = e + chr(x).lower() 39 cmap[chr(x)] = e + chr(x).lower()
40 dmap = {} 40 dmap = {}
43 def decode(s): 43 def decode(s):
44 i = 0 44 i = 0
45 while i < len(s): 45 while i < len(s):
46 for l in xrange(1, 4): 46 for l in xrange(1, 4):
47 try: 47 try:
48 yield dmap[s[i:i+l]] 48 yield dmap[s[i:i + l]]
49 i += l 49 i += l
50 break 50 break
51 except KeyError: 51 except KeyError:
52 pass 52 pass
53 else: 53 else:
57 57
58 encodefilename, decodefilename = _buildencodefun() 58 encodefilename, decodefilename = _buildencodefun()
59 59
60 def _build_lower_encodefun(): 60 def _build_lower_encodefun():
61 win_reserved = [ord(x) for x in '\\:*?"<>|'] 61 win_reserved = [ord(x) for x in '\\:*?"<>|']
62 cmap = dict([ (chr(x), chr(x)) for x in xrange(127) ]) 62 cmap = dict([(chr(x), chr(x)) for x in xrange(127)])
63 for x in (range(32) + range(126, 256) + win_reserved): 63 for x in (range(32) + range(126, 256) + win_reserved):
64 cmap[chr(x)] = "~%02x" % x 64 cmap[chr(x)] = "~%02x" % x
65 for x in range(ord("A"), ord("Z")+1): 65 for x in range(ord("A"), ord("Z")+1):
66 cmap[chr(x)] = chr(x).lower() 66 cmap[chr(x)] = chr(x).lower()
67 return lambda s: "".join([cmap[c] for c in s]) 67 return lambda s: "".join([cmap[c] for c in s])