Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/subrepo.py @ 46401: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 | 59fa3890d40a |
children | e2f7b2695ba1 |
comparison
equal
deleted
inserted
replaced
46400:5f86765c9707 | 46401:d6601547f22b |
---|---|
1874 if match and not match(bname): | 1874 if match and not match(bname): |
1875 continue | 1875 continue |
1876 if info.issym(): | 1876 if info.issym(): |
1877 data = info.linkname | 1877 data = info.linkname |
1878 else: | 1878 else: |
1879 data = tar.extractfile(info).read() | 1879 f = tar.extractfile(info) |
1880 if f: | |
1881 data = f.read() | |
1882 else: | |
1883 self.ui.warn(_(b'skipping "%s" (unknown type)') % bname) | |
1884 continue | |
1880 archiver.addfile(prefix + bname, info.mode, info.issym(), data) | 1885 archiver.addfile(prefix + bname, info.mode, info.issym(), data) |
1881 total += 1 | 1886 total += 1 |
1882 progress.increment() | 1887 progress.increment() |
1883 progress.complete() | 1888 progress.complete() |
1884 return total | 1889 return total |