Mercurial > hg
changeset 46694:d6601547f22b stable
subrepo: handle unexpected file types from git gracefully
This was flagged by pytype because `tar.extractfile(...)` can return None if the
entry is not a file or symlink. I don't think that git supports other types,
but better safe than sorry.
Differential Revision: https://phab.mercurial-scm.org/D10179
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 11 Mar 2021 19:21:58 -0500 |
parents | 5f86765c9707 |
children | 8da44c36fc74 |
files | mercurial/subrepo.py |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/subrepo.py Thu Mar 11 18:45:18 2021 -0500 +++ b/mercurial/subrepo.py Thu Mar 11 19:21:58 2021 -0500 @@ -1876,7 +1876,12 @@ if info.issym(): data = info.linkname else: - data = tar.extractfile(info).read() + f = tar.extractfile(info) + if f: + data = f.read() + else: + self.ui.warn(_(b'skipping "%s" (unknown type)') % bname) + continue archiver.addfile(prefix + bname, info.mode, info.issym(), data) total += 1 progress.increment()