Patchwork D9078: repoview: don't crash if mergestate points to non-existent node

login
register
mail settings
Submitter phabricator
Date Sept. 23, 2020, 11:11 p.m.
Message ID <differential-rev-PHID-DREV-at234qt4cuabd7zu43zo-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47271/
State Superseded
Headers show

Comments

phabricator - Sept. 23, 2020, 11:11 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/repoview.py
  tests/test-obsolete.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -1826,8 +1826,8 @@ 
     ancestor path: file (node bc7ebe2d260cff30d2a39a130d84add36216f791)
     other path: file (node b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3)
     extra: ancestorlinknode = b73b8c9a4ab4da89a5a35a6f10dfb13edc84ca37
-BROKEN: We should be able to see the log (without the deleted commit, of course)
+We should be able to see the log (without the deleted commit, of course)
   $ hg log -G
-  abort: unknown revision 'b73b8c9a4ab4da89a5a35a6f10dfb13edc84ca37'!
-  [255]
+  @  0:f53e9479dce5 (draft) [tip ] first
+  
   $ cd ..
diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -70,8 +70,10 @@ 
 
     ms = mergestate.mergestate.read(repo)
     if ms.active():
-        pinned.add(ms.localctx.rev())
-        pinned.add(ms.otherctx.rev())
+        for node in (ms.local, ms.other):
+            rev = cl.index.get_rev(node)
+            if rev is not None:
+                pinned.add(rev)
 
     return pinned