[PATCH STABLE] status: don't crash if a lookup file disappears

Siddharth Agarwal sid at less-broken.com
Sat Jun 3 11:58:05 EDT 2017


On 6/3/17 7:26 AM, Yuya Nishihara wrote:
> On Fri, 2 Jun 2017 22:28:07 -0700, Siddharth Agarwal wrote:
>> # HG changeset patch
>> # User Siddharth Agarwal <sid0 at fb.com>
>> # Date 1496467672 25200
>> #      Fri Jun 02 22:27:52 2017 -0700
>> # Branch stable
>> # Node ID d39f934da0c80a568486cd8645eb6bbe513f1f03
>> # Parent  62e42e2897502bcbaa3a57d3301c789309596391
>> status: don't crash if a lookup file disappears
> Looks good to me. A few nits.
>
>> diff --git a/mercurial/context.py b/mercurial/context.py
>> --- a/mercurial/context.py
>> +++ b/mercurial/context.py
>> @@ -1613,18 +1613,30 @@ class workingctx(committablectx):
>>       def _checklookup(self, files):
>>           # check for any possibly clean files
>>           if not files:
>> -            return [], []
>> +            return [], [], []
>>   
>>           modified = []
>> +        deleted = []
>>           fixup = []
>>           pctx = self._parents[0]
>>           # do a full compare of any files that might have changed
>>           for f in sorted(files):
>> -            if (f not in pctx or self.flags(f) != pctx.flags(f)
>> -                or pctx[f].cmp(self[f])):
>> -                modified.append(f)
>> -            else:
>> -                fixup.append(f)
>> +            try:
>> +                # This will return True for a file that got replaced by a
>> +                # directory in the interim, but fixing that is pretty hard.
>> +                if (f not in pctx or self.flags(f) != pctx.flags(f)
>> +                    or pctx[f].cmp(self[f])):
> If cmp() falls back to fctx.data() path, maybe IOError could be raised.

That sounds like a good idea. (Sorry, I've been writing some Python 3 
where OSError and IOError are the same.)

>
>> +                    modified.append(f)
>> +                else:
>> +                    fixup.append(f)
>> +            except OSError:
> Can we check errno strictly? Perhaps ENOENT and EISDIR should be caught.

The dirstate doesn't check errno strictly, and I think both the dirstate 
and this should do the same thing.

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel




More information about the Mercurial-devel mailing list