D1506: dagop: handle IndexError when using wdir() in dag range

swhitaker (Simon Whitaker) phabricator at mercurial-scm.org
Fri Nov 24 12:06:57 UTC 2017


swhitaker created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Using wdir() in a dag range revset can crash Mercurial. For example:
  
    hg status --rev '.^::wdir()
  
  revlog.c reports an IndexError in this instance, but it isn't caught
  by the calling code. This change adds IndexError to the set of exception
  types the calling code catches. When an IndexError is caught, the code
  falls back to calling the pure Python implementation of reachableroots,
  which fails gracefully.

TEST PLAN
  $ hg status --rev '.::wdir()'
  abort: working directory revision cannot be specified

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/dagop.py

CHANGE DETAILS

diff --git a/mercurial/dagop.py b/mercurial/dagop.py
--- a/mercurial/dagop.py
+++ b/mercurial/dagop.py
@@ -230,7 +230,7 @@
     heads = list(heads)
     try:
         revs = repo.changelog.reachableroots(minroot, heads, roots, includepath)
-    except AttributeError:
+    except (AttributeError, IndexError):
         revs = _reachablerootspure(repo, minroot, roots, heads, includepath)
     revs = baseset(revs)
     revs.sort()



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


More information about the Mercurial-devel mailing list