[PATCH STABLE] filelog: don't crash on invalid copy metadata (issue5748)

Anton Shestakov av6 at dwimlabs.net
Thu Nov 30 23:19:47 EST 2017


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 bugs,
> +            # 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:

?


More information about the Mercurial-devel mailing list