comparison mercurial/changelog.py @ 35671:8810f0643fa1

changelog: introduce a 'tiprev' method Accessing tiprev is a common need through the code base. It is usually done using "len(changelog) -1". That form is tedious and error-prone. For example, it will give wrong results on filtered changelog (if the unfiltered tip is filtered). As a result, we introduce a simple 'tiprev()' method to provide this exact information in a nice way.
author Boris Feld <boris.feld@octobus.net>
date Thu, 04 May 2017 02:23:21 +0200
parents 137a08d82232
children 5a6e0eee7781
comparison
equal deleted inserted replaced
35670:2b9e2415f5b5 35671:8810f0643fa1
293 self._delayed = False 293 self._delayed = False
294 self._delaybuf = None 294 self._delaybuf = None
295 self._divert = False 295 self._divert = False
296 self.filteredrevs = frozenset() 296 self.filteredrevs = frozenset()
297 297
298 def tiprev(self):
299 for i in xrange(len(self) -1, -2, -1):
300 if i not in self.filteredrevs:
301 return i
302
298 def tip(self): 303 def tip(self):
299 """filtered version of revlog.tip""" 304 """filtered version of revlog.tip"""
300 for i in xrange(len(self) -1, -2, -1): 305 for i in xrange(len(self) -1, -2, -1):
301 if i not in self.filteredrevs: 306 if i not in self.filteredrevs:
302 return self.node(i) 307 return self.node(i)