D4281: branchmap: load branchmap as an iterable

Yuya Nishihara yuya at tcha.org
Thu Aug 16 06:35:50 EDT 2018


>  def read(repo):
>      try:
>          f = repo.cachevfs(_filename(repo))
> -        lines = f.read().split('\n')
> -        f.close()
> -    except (IOError, OSError):
> -        return None
> -
> -    try:
> -        cachekey = lines.pop(0).split(" ", 2)
> +        cachekey = next(f).split(" ", 2)

Several tests fail, probably because of missed rstrip().

>              partial.setdefault(label, []).append(node)
>              if state == 'c':
>                  partial._closednodes.add(node)
> +
> +    except (IOError, OSError):
> +        return None
> +
>      except Exception as inst:
>          if repo.ui.debugflag:
>              msg = 'invalid branchheads cache'

Missed `finally: f.close()`?


More information about the Mercurial-devel mailing list