[PATCH STABLE] filelog: don't crash on invalid copy metadata (issue5748)
gregory.szorc at gmail.com
Fri Dec 1 00:34:17 EST 2017
On Thu, Nov 30, 2017 at 11:19 PM, Anton Shestakov <av6 at dwimlabs.net> wrote:
> On Thu, 30 Nov 2017 21:22:10 -0500
> Gregory Szorc <gregory.szorc at gmail.com> wrote:
> > - if m and "copy" in m:
> > - return (m["copy"], revlog.bin(m["copyrev"]))
> > + if m:
> > + # copy and copyrev occur in pairs. In rare cases due to
> > + # one can occur without the other.
> > + try:
> > + copy, copyrev = m['copy'], m['copyrev']
> > + return copy, revlog.bin(copyrev)
> > + except KeyError:
> > + pass
> > +
> Can't help but ask: why not just
> if m and "copy" in m and "copyrev" in m:
I have a personal aversion to redundant key lookups. Not that it matters
much here: we're using a builtin dict and the lookup should be very fast.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mercurial-devel