Show More
@@ -1091,18 +1091,25 b' def open_template(name, templatepath=Non' | |||||
1091 | will be read from the mercurial.templates package instead. The returned path |
|
1091 | will be read from the mercurial.templates package instead. The returned path | |
1092 | will then be the relative path. |
|
1092 | will then be the relative path. | |
1093 | ''' |
|
1093 | ''' | |
|
1094 | # Does the name point directly to a map file? | |||
|
1095 | if os.path.isabs(name): | |||
|
1096 | return name, open(name, mode='rb') | |||
|
1097 | ||||
|
1098 | # Does the name point to a template in the provided templatepath, or | |||
|
1099 | # in mercurial/templates/ if no path was provided? | |||
1094 | if templatepath is None: |
|
1100 | if templatepath is None: | |
1095 | templatepath = templatedir() |
|
1101 | templatepath = templatedir() | |
1096 |
if templatepath is not None |
|
1102 | if templatepath is not None: | |
1097 | f = os.path.join(templatepath, name) |
|
1103 | f = os.path.join(templatepath, name) | |
1098 | return f, open(f, mode='rb') |
|
1104 | return f, open(f, mode='rb') | |
1099 | else: |
|
1105 | ||
1100 | name_parts = pycompat.sysstr(name).split('/') |
|
1106 | # Otherwise try to read it using the resources API | |
1101 | package_name = '.'.join(['mercurial', 'templates'] + name_parts[:-1]) |
|
1107 | name_parts = pycompat.sysstr(name).split('/') | |
1102 | return ( |
|
1108 | package_name = '.'.join(['mercurial', 'templates'] + name_parts[:-1]) | |
1103 | name, |
|
1109 | return ( | |
1104 | resourceutil.open_resource(package_name, name_parts[-1]), |
|
1110 | name, | |
1105 | ) |
|
1111 | resourceutil.open_resource(package_name, name_parts[-1]), | |
|
1112 | ) | |||
1106 |
|
1113 | |||
1107 |
|
1114 | |||
1108 | def try_open_template(name, templatepath=None): |
|
1115 | def try_open_template(name, templatepath=None): |
General Comments 0
You need to be logged in to leave comments.
Login now