Patchwork D1764: revlog: don't use slicing to return parents

login
register
mail settings
Submitter phabricator
Date Dec. 27, 2017, 12:35 a.m.
Message ID <differential-rev-PHID-DREV-qvmcswisp4wu5xe4jlx2-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26451/
State Superseded
Headers show

Comments

phabricator - Dec. 27, 2017, 12:35 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1764

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -622,12 +622,14 @@ 
 
     def parentrevs(self, rev):
         try:
-            return self.index[rev][5:7]
+            entry = self.index[rev]
         except IndexError:
             if rev == wdirrev:
                 raise error.WdirUnsupported
             raise
 
+        return entry[5], entry[6]
+
     def node(self, rev):
         try:
             return self.index[rev][7]