Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 35521:a0fab647a8f1
revlog: don't use slicing to return parents
This is the only place we use a slice on index entries, which
are currently tuples. In preparation for moving away from tuples,
let's stop using slices so we don't have to implement that support
on the new type.
We also tweak the logic slightly so the exception only catches the
IndexError on the index lookup, not on the index entry lookup. The
old code should never have been buggy. But it was semantically wrong.
Differential Revision: https://phab.mercurial-scm.org/D1764
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 25 Dec 2017 16:31:14 -0700 |
parents | 6226668a7169 |
children | b43578ec483a |
comparison
equal
deleted
inserted
replaced
35520:711149d8e676 | 35521:a0fab647a8f1 |
---|---|
620 def linkrev(self, rev): | 620 def linkrev(self, rev): |
621 return self.index[rev][4] | 621 return self.index[rev][4] |
622 | 622 |
623 def parentrevs(self, rev): | 623 def parentrevs(self, rev): |
624 try: | 624 try: |
625 return self.index[rev][5:7] | 625 entry = self.index[rev] |
626 except IndexError: | 626 except IndexError: |
627 if rev == wdirrev: | 627 if rev == wdirrev: |
628 raise error.WdirUnsupported | 628 raise error.WdirUnsupported |
629 raise | 629 raise |
630 | |
631 return entry[5], entry[6] | |
630 | 632 |
631 def node(self, rev): | 633 def node(self, rev): |
632 try: | 634 try: |
633 return self.index[rev][7] | 635 return self.index[rev][7] |
634 except IndexError: | 636 except IndexError: |