comparison mercurial/manifest.py @ 24147:ba4fcd80079d

manifest: rename 'mf', 'map', and 'mapping' to 'm' We mostly call manifest variables 'm', so let's use that in manifest.py too. This makes it clearer that the variables do, in fact, contain manifestsdict instances and never a plain dict.
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 24 Feb 2015 09:08:54 -0800
parents dd8c891dd09a
children cd66080ef6d4
comparison
equal deleted inserted replaced
24146:dd8c891dd09a 24147:ba4fcd80079d
46 files = match.files() 46 files = match.files()
47 if (match.matchfn == match.exact or 47 if (match.matchfn == match.exact or
48 (not match.anypats() and util.all(fn in self for fn in files))): 48 (not match.anypats() and util.all(fn in self for fn in files))):
49 return self.intersectfiles(files) 49 return self.intersectfiles(files)
50 50
51 mf = self.copy() 51 m = self.copy()
52 for fn in mf.keys(): 52 for fn in m.keys():
53 if not match(fn): 53 if not match(fn):
54 del mf[fn] 54 del m[fn]
55 return mf 55 return m
56 56
57 def diff(self, m2, clean=False): 57 def diff(self, m2, clean=False):
58 '''Finds changes between the current manifest and m2. 58 '''Finds changes between the current manifest and m2.
59 59
60 Args: 60 Args:
245 return manifestdict() # don't upset local cache 245 return manifestdict() # don't upset local cache
246 if node in self._mancache: 246 if node in self._mancache:
247 return self._mancache[node][0] 247 return self._mancache[node][0]
248 text = self.revision(node) 248 text = self.revision(node)
249 arraytext = array.array('c', text) 249 arraytext = array.array('c', text)
250 mapping = _parse(text) 250 m = _parse(text)
251 self._mancache[node] = (mapping, arraytext) 251 self._mancache[node] = (m, arraytext)
252 return mapping 252 return m
253 253
254 def find(self, node, f): 254 def find(self, node, f):
255 '''look up entry for a single file efficiently. 255 '''look up entry for a single file efficiently.
256 return (node, flags) pair if found, (None, None) if not.''' 256 return (node, flags) pair if found, (None, None) if not.'''
257 if node in self._mancache: 257 if node in self._mancache:
258 mapping = self._mancache[node][0] 258 m = self._mancache[node][0]
259 return mapping.get(f), mapping.flags(f) 259 return m.get(f), m.flags(f)
260 text = self.revision(node) 260 text = self.revision(node)
261 start, end = _msearch(text, f) 261 start, end = _msearch(text, f)
262 if start == end: 262 if start == end:
263 return None, None 263 return None, None
264 l = text[start:end] 264 l = text[start:end]
265 f, n = l.split('\0') 265 f, n = l.split('\0')
266 return revlog.bin(n[:40]), n[40:-1] 266 return revlog.bin(n[:40]), n[40:-1]
267 267
268 def add(self, map, transaction, link, p1, p2, added, removed): 268 def add(self, m, transaction, link, p1, p2, added, removed):
269 if p1 in self._mancache: 269 if p1 in self._mancache:
270 # If our first parent is in the manifest cache, we can 270 # If our first parent is in the manifest cache, we can
271 # compute a delta here using properties we know about the 271 # compute a delta here using properties we know about the
272 # manifest up-front, which may save time later for the 272 # manifest up-front, which may save time later for the
273 # revlog layer. 273 # revlog layer.
278 work.extend((x, True) for x in removed) 278 work.extend((x, True) for x in removed)
279 # this could use heapq.merge() (from Python 2.6+) or equivalent 279 # this could use heapq.merge() (from Python 2.6+) or equivalent
280 # since the lists are already sorted 280 # since the lists are already sorted
281 work.sort() 281 work.sort()
282 282
283 arraytext, deltatext = map.fastdelta(self._mancache[p1][1], work) 283 arraytext, deltatext = m.fastdelta(self._mancache[p1][1], work)
284 cachedelta = self.rev(p1), deltatext 284 cachedelta = self.rev(p1), deltatext
285 text = util.buffer(arraytext) 285 text = util.buffer(arraytext)
286 else: 286 else:
287 # The first parent manifest isn't already loaded, so we'll 287 # The first parent manifest isn't already loaded, so we'll
288 # just encode a fulltext of the manifest and pass that 288 # just encode a fulltext of the manifest and pass that
289 # through to the revlog layer, and let it handle the delta 289 # through to the revlog layer, and let it handle the delta
290 # process. 290 # process.
291 text = map.text() 291 text = m.text()
292 arraytext = array.array('c', text) 292 arraytext = array.array('c', text)
293 cachedelta = None 293 cachedelta = None
294 294
295 n = self.addrevision(text, transaction, link, p1, p2, cachedelta) 295 n = self.addrevision(text, transaction, link, p1, p2, cachedelta)
296 self._mancache[n] = (map, arraytext) 296 self._mancache[n] = (m, arraytext)
297 297
298 return n 298 return n