[PATCH 2 of 2] cat: do not instantiate subrepo if no potential match in it

Matt Harbison mharbison72 at gmail.com
Mon Dec 4 03:17:21 UTC 2017


On Mon, 27 Nov 2017 07:35:04 -0500, Yuya Nishihara <yuya at tcha.org> wrote:

> On Sun, 26 Nov 2017 20:11:25 -0500, Matt Harbison wrote:
>> On Sun, 26 Nov 2017 05:38:53 -0500, Yuya Nishihara <yuya at tcha.org>  
>> wrote:
>> > On Sat, 25 Nov 2017 23:53:45 -0500, Matt Harbison wrote:
>> >> It's probably beyond the scope of what you were fixing, but should  
>> all
>> >> subrepo recursion be guarded like this?
>> >>
>> >> >          sub = ctx.sub(subpath)
>> >> >          try:
>> >> >              submatch = matchmod.subdirmatcher(subpath, matcher)
>> >
>> > Maybe we'll need ctx.walksub(matcher) which yields (subrepo,  
>> submatcher)
>> > pairs?
>>
>> I like it.
>>
>> I wonder if the exception handler that prints 'skipping..' can be rolled
>> in too.
>
> I think that's up to a caller whether a missing subrepo can be ignored  
> or not.

I agree in theory.  I was thinking if the majority of the callers did one  
thing, the others could change the default behavior by passing an optional  
callback.  Or maybe there are a couple of predefined callback handlers,  
and everyone has to pass one.  (I wonder how many places aren't handling  
the errors because of oversight.)  But maybe that's too awkward.

>> At least cmdutil.add() and cmdutil.cat() catch different things,
>> and I have a vague recollection that there was also some uncaught
>> exception in this area.  (I don't recall what it was, maybe the subrepo
>> being completely missing?)
>
> Perhaps catching error.LookupError is wrong. It's the exception raised  
> when
> ambiguous identifier is passed to repo[].


More information about the Mercurial-devel mailing list