comparison mercurial/branchmap.py @ 42002:662ffdde5adf

branchcache: rename itervalues() to iterheads() The itervalues() exists because branchcache() had a dict interface. Since it no longer has a dict interface, it makes sense to have better function names. If a person does not understand how branchcache stores info, it will be hard for them to guess what itervalues() does. Differential Revision: https://phab.mercurial-scm.org/D6152
author Pulkit Goyal <pulkit@yandex-team.ru>
date Mon, 18 Mar 2019 19:01:29 +0300
parents 624d6683c705
children 7546bf46bfcd
comparison
equal deleted inserted replaced
42001:624d6683c705 42002:662ffdde5adf
175 def setdefault(self, *args): 175 def setdefault(self, *args):
176 return self.entries.setdefault(*args) 176 return self.entries.setdefault(*args)
177 177
178 def iteritems(self): 178 def iteritems(self):
179 return self.entries.iteritems() 179 return self.entries.iteritems()
180
181 def itervalues(self):
182 return self.entries.itervalues()
183 180
184 @classmethod 181 @classmethod
185 def fromfile(cls, repo): 182 def fromfile(cls, repo):
186 f = None 183 f = None
187 try: 184 try:
284 return heads 281 return heads
285 282
286 def iterbranches(self): 283 def iterbranches(self):
287 for bn, heads in self.iteritems(): 284 for bn, heads in self.iteritems():
288 yield (bn, heads) + self._branchtip(heads) 285 yield (bn, heads) + self._branchtip(heads)
286
287 def iterheads(self):
288 """ returns all the heads """
289 return self.entries.itervalues()
289 290
290 def copy(self): 291 def copy(self):
291 """return an deep copy of the branchcache object""" 292 """return an deep copy of the branchcache object"""
292 return branchcache( 293 return branchcache(
293 self.entries, self.tipnode, self.tiprev, self.filteredhash, 294 self.entries, self.tipnode, self.tiprev, self.filteredhash,
367 368
368 if not self.validfor(repo): 369 if not self.validfor(repo):
369 # cache key are not valid anymore 370 # cache key are not valid anymore
370 self.tipnode = nullid 371 self.tipnode = nullid
371 self.tiprev = nullrev 372 self.tiprev = nullrev
372 for heads in self.itervalues(): 373 for heads in self.iterheads():
373 tiprev = max(cl.rev(node) for node in heads) 374 tiprev = max(cl.rev(node) for node in heads)
374 if tiprev > self.tiprev: 375 if tiprev > self.tiprev:
375 self.tipnode = cl.node(tiprev) 376 self.tipnode = cl.node(tiprev)
376 self.tiprev = tiprev 377 self.tiprev = tiprev
377 self.filteredhash = scmutil.filteredhash(repo, self.tiprev) 378 self.filteredhash = scmutil.filteredhash(repo, self.tiprev)