Show More
@@ -852,9 +852,12 b' def _readmapfile(fp, mapfile):' | |||||
852 | if not subresource: |
|
852 | if not subresource: | |
853 | if pycompat.ossep not in rel: |
|
853 | if pycompat.ossep not in rel: | |
854 | abs = rel |
|
854 | abs = rel | |
855 | subresource = resourceutil.open_resource( |
|
855 | try: | |
856 | b'mercurial.templates', rel |
|
856 | subresource = resourceutil.open_resource( | |
857 | ) |
|
857 | b'mercurial.templates', rel | |
|
858 | ) | |||
|
859 | except resourceutil.FileNotFoundError: | |||
|
860 | subresource = None | |||
858 | else: |
|
861 | else: | |
859 | dir = templatedir() |
|
862 | dir = templatedir() | |
860 | if dir: |
|
863 | if dir: |
@@ -64,6 +64,11 b' try:' | |||||
64 | # Force loading of the resources module |
|
64 | # Force loading of the resources module | |
65 | resources.open_binary # pytype: disable=module-attr |
|
65 | resources.open_binary # pytype: disable=module-attr | |
66 |
|
66 | |||
|
67 | # pytype: disable=import-error | |||
|
68 | from importlib.resources import FileNotFoundError | |||
|
69 | ||||
|
70 | # pytype: enable=import-error | |||
|
71 | ||||
67 | def open_resource(package, name): |
|
72 | def open_resource(package, name): | |
68 | return resources.open_binary( # pytype: disable=module-attr |
|
73 | return resources.open_binary( # pytype: disable=module-attr | |
69 | pycompat.sysstr(package), pycompat.sysstr(name) |
|
74 | pycompat.sysstr(package), pycompat.sysstr(name) | |
@@ -85,6 +90,9 b' except (ImportError, AttributeError):' | |||||
85 | # importlib.resources was not found (almost definitely because we're on a |
|
90 | # importlib.resources was not found (almost definitely because we're on a | |
86 | # Python version before 3.7) |
|
91 | # Python version before 3.7) | |
87 |
|
92 | |||
|
93 | class FileNotFoundError(RuntimeError): | |||
|
94 | pass | |||
|
95 | ||||
88 | def open_resource(package, name): |
|
96 | def open_resource(package, name): | |
89 | path = os.path.join(_package_path(package), name) |
|
97 | path = os.path.join(_package_path(package), name) | |
90 | return open(path, "rb") |
|
98 | return open(path, "rb") |
General Comments 0
You need to be logged in to leave comments.
Login now