comparison mercurial/localrepo.py @ 7622:4dd7b28003d2

use dict.iteritems() rather than dict.items() This should be faster and more future-proof. Calls where the result is to be sorted using util.sort() have been left unchanged. Calls to .items() on configparser objects have been left as-is, too.
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Mon, 12 Jan 2009 09:16:03 +0100
parents 7bf7c073375e
children 08cabecfa8a8
comparison
equal deleted inserted replaced
7621:6d891df43a5f 7622:4dd7b28003d2
263 if key in filetags: 263 if key in filetags:
264 n, h = filetags[key] 264 n, h = filetags[key]
265 h.append(n) 265 h.append(n)
266 filetags[key] = (bin_n, h) 266 filetags[key] = (bin_n, h)
267 267
268 for k, nh in filetags.items(): 268 for k, nh in filetags.iteritems():
269 if k not in globaltags: 269 if k not in globaltags:
270 globaltags[k] = nh 270 globaltags[k] = nh
271 tagtypes[k] = tagtype 271 tagtypes[k] = tagtype
272 continue 272 continue
273 273
299 except IOError: 299 except IOError:
300 pass 300 pass
301 301
302 self.tagscache = {} 302 self.tagscache = {}
303 self._tagstypecache = {} 303 self._tagstypecache = {}
304 for k,nh in globaltags.items(): 304 for k, nh in globaltags.iteritems():
305 n = nh[0] 305 n = nh[0]
306 if n != nullid: 306 if n != nullid:
307 self.tagscache[k] = n 307 self.tagscache[k] = n
308 self._tagstypecache[k] = tagtypes[k] 308 self._tagstypecache[k] = tagtypes[k]
309 self.tagscache['tip'] = self.changelog.tip() 309 self.tagscache['tip'] = self.changelog.tip()
341 return [item for item in ret if item] 341 return [item for item in ret if item]
342 342
343 def tagslist(self): 343 def tagslist(self):
344 '''return a list of tags ordered by revision''' 344 '''return a list of tags ordered by revision'''
345 l = [] 345 l = []
346 for t, n in self.tags().items(): 346 for t, n in self.tags().iteritems():
347 try: 347 try:
348 r = self.changelog.rev(n) 348 r = self.changelog.rev(n)
349 except: 349 except:
350 r = -2 # sort to the beginning of the list if unknown 350 r = -2 # sort to the beginning of the list if unknown
351 l.append((r, t, n)) 351 l.append((r, t, n))
353 353
354 def nodetags(self, node): 354 def nodetags(self, node):
355 '''return the tags associated with a node''' 355 '''return the tags associated with a node'''
356 if not self.nodetagscache: 356 if not self.nodetagscache:
357 self.nodetagscache = {} 357 self.nodetagscache = {}
358 for t, n in self.tags().items(): 358 for t, n in self.tags().iteritems():
359 self.nodetagscache.setdefault(n, []).append(t) 359 self.nodetagscache.setdefault(n, []).append(t)
360 return self.nodetagscache.get(node, []) 360 return self.nodetagscache.get(node, [])
361 361
362 def _branchtags(self, partial, lrev): 362 def _branchtags(self, partial, lrev):
363 tiprev = len(self) - 1 363 tiprev = len(self) - 1
386 386
387 self._branchtags(partial, lrev) 387 self._branchtags(partial, lrev)
388 388
389 # the branch cache is stored on disk as UTF-8, but in the local 389 # the branch cache is stored on disk as UTF-8, but in the local
390 # charset internally 390 # charset internally
391 for k, v in partial.items(): 391 for k, v in partial.iteritems():
392 self.branchcache[util.tolocal(k)] = v 392 self.branchcache[util.tolocal(k)] = v
393 self._ubranchcache = partial 393 self._ubranchcache = partial
394 return self.branchcache 394 return self.branchcache
395 395
396 def _readbranchcache(self): 396 def _readbranchcache(self):
1754 if r == next_rev[0]: 1754 if r == next_rev[0]:
1755 # If the last rev we looked at was the one just previous, 1755 # If the last rev we looked at was the one just previous,
1756 # we only need to see a diff. 1756 # we only need to see a diff.
1757 deltamf = mnfst.readdelta(mnfstnode) 1757 deltamf = mnfst.readdelta(mnfstnode)
1758 # For each line in the delta 1758 # For each line in the delta
1759 for f, fnode in deltamf.items(): 1759 for f, fnode in deltamf.iteritems():
1760 f = changedfiles.get(f, None) 1760 f = changedfiles.get(f, None)
1761 # And if the file is in the list of files we care 1761 # And if the file is in the list of files we care
1762 # about. 1762 # about.
1763 if f is not None: 1763 if f is not None:
1764 # Get the changenode this manifest belongs to 1764 # Get the changenode this manifest belongs to