comparison mercurial/manifest.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 69e0bcf36961
comparison
equal deleted inserted replaced
10281:e7d3b509af8b 10282:08a0f04b56bd
9 import mdiff, parsers, error, revlog 9 import mdiff, parsers, error, revlog
10 import array, struct 10 import array, struct
11 11
12 class manifestdict(dict): 12 class manifestdict(dict):
13 def __init__(self, mapping=None, flags=None): 13 def __init__(self, mapping=None, flags=None):
14 if mapping is None: mapping = {} 14 if mapping is None:
15 if flags is None: flags = {} 15 mapping = {}
16 if flags is None:
17 flags = {}
16 dict.__init__(self, mapping) 18 dict.__init__(self, mapping)
17 self._flags = flags 19 self._flags = flags
18 def flags(self, f): 20 def flags(self, f):
19 return self._flags.get(f, "") 21 return self._flags.get(f, "")
20 def set(self, f, flags): 22 def set(self, f, flags):
68 if not hi: 70 if not hi:
69 hi = lenm 71 hi = lenm
70 while lo < hi: 72 while lo < hi:
71 mid = (lo + hi) // 2 73 mid = (lo + hi) // 2
72 start = mid 74 start = mid
73 while start > 0 and m[start-1] != '\n': 75 while start > 0 and m[start - 1] != '\n':
74 start -= 1 76 start -= 1
75 end = advance(start, '\0') 77 end = advance(start, '\0')
76 if m[start:end] < s: 78 if m[start:end] < s:
77 # we know that after the null there are 40 bytes of sha1 79 # we know that after the null there are 40 bytes of sha1
78 # this translates to the bisect lo = mid + 1 80 # this translates to the bisect lo = mid + 1
83 end = advance(lo, '\0') 85 end = advance(lo, '\0')
84 found = m[lo:end] 86 found = m[lo:end]
85 if cmp(s, found) == 0: 87 if cmp(s, found) == 0:
86 # we know that after the null there are 40 bytes of sha1 88 # we know that after the null there are 40 bytes of sha1
87 end = advance(end + 40, '\n') 89 end = advance(end + 40, '\n')
88 return (lo, end+1) 90 return (lo, end + 1)
89 else: 91 else:
90 return (lo, lo) 92 return (lo, lo)
91 93
92 def find(self, node, f): 94 def find(self, node, f):
93 '''look up entry for a single file efficiently. 95 '''look up entry for a single file efficiently.