D2938: grep: make grep search on working directory by default
Yuya Nishihara
yuya at tcha.org
Fri May 25 09:13:26 EDT 2018
> So I was working on it, but the way I tried to correct "wdir()" is by handling it as a special case, so introducing an "if" block again similar to this.
> But you were asking to eliminate the if/else block altogether, I wonder if there is way ?
IIRC, my point was to avoid adding *big* if/else branch which will be likely
to introduce untested code paths.
I don't think there would be a way to go without if/else or try/except as
long as we use the low-level filelog API for performance reasons. Perhaps,
we'll have to catch WdirUnsupported error to fall back to the filectx API.
```
try:
flog.read(fnode)
except error.WdirUnsupported:
ctx[fn].data()
```
More information about the Mercurial-devel
mailing list