Page MenuHomePhabricator

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

Authored by swhitaker on Nov 24 2017, 7:06 AM.

Details

Reviewers
mbthomas
yuja
Group Reviewers
hg-reviewers
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

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

swhitaker created this revision.Nov 24 2017, 7:06 AM
mbthomas accepted this revision.Nov 24 2017, 11:31 AM
yuja requested changes to this revision.Nov 24 2017, 10:54 PM
yuja added a subscriber: yuja.

I think it's better to fail fast instead of trying the slow path which is supposed
to raise WdirUnsupported exception.

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

Can you add test?

This revision now requires changes to proceed.Nov 24 2017, 10:54 PM

I understand that fixing the crash is a good first step, but ideally, wouldn't this be supported? Is there a reason it's particularly hard to support?

yuja added a comment.Nov 26 2017, 9:01 AM

but ideally, wouldn't this be supported?

Yeah, this case, includepath=True, won't be difficult to handle. If reachableroots() raised
WdirUnsupportedError, drop wdir revision from y of x::y, add parents instead, rerun
x::(y - wdir() + parents(wdir())), and append wdir to the result.