Show More
@@ -1672,7 +1672,7 b' def debuginstall(ui, **opts):' | |||
|
1672 | 1672 | fm.write(b'templatedirs', b'checking templates (%s)...\n', p or b'') |
|
1673 | 1673 | fm.condwrite(not p, b'', _(b" no template directories found\n")) |
|
1674 | 1674 | if p: |
|
1675 | (m, fp) = templater.open_template(b"map-cmdline.default") | |
|
1675 | (m, fp) = templater.try_open_template(b"map-cmdline.default") | |
|
1676 | 1676 | if m: |
|
1677 | 1677 | # template found, check if it is working |
|
1678 | 1678 | err = None |
@@ -600,9 +600,9 b' def lookuptemplate(ui, topic, tmpl):' | |||
|
600 | 600 | |
|
601 | 601 | # perhaps a stock style? |
|
602 | 602 | if not os.path.split(tmpl)[0]: |
|
603 | (mapname, fp) = templater.open_template( | |
|
603 | (mapname, fp) = templater.try_open_template( | |
|
604 | 604 | b'map-cmdline.' + tmpl |
|
605 | ) or templater.open_template(tmpl) | |
|
605 | ) or templater.try_open_template(tmpl) | |
|
606 | 606 | if mapname: |
|
607 | 607 | return mapfile_templatespec(topic, mapname, fp) |
|
608 | 608 |
@@ -78,7 +78,7 b' def _stylemap(styles, path=None):' | |||
|
78 | 78 | locations = (os.path.join(style, b'map'), b'map-' + style, b'map') |
|
79 | 79 | |
|
80 | 80 | for location in locations: |
|
81 | mapfile, fp = templater.open_template(location, path) | |
|
81 | mapfile, fp = templater.try_open_template(location, path) | |
|
82 | 82 | if mapfile: |
|
83 | 83 | return style, mapfile, fp |
|
84 | 84 |
@@ -628,9 +628,9 b' def _lookuptemplate(ui, tmpl, style):' | |||
|
628 | 628 | mapfile = style |
|
629 | 629 | fp = None |
|
630 | 630 | if not os.path.split(mapfile)[0]: |
|
631 | (mapname, fp) = templater.open_template( | |
|
631 | (mapname, fp) = templater.try_open_template( | |
|
632 | 632 | b'map-cmdline.' + mapfile |
|
633 | ) or templater.open_template(mapfile) | |
|
633 | ) or templater.try_open_template(mapfile) | |
|
634 | 634 | if mapname: |
|
635 | 635 | mapfile = mapname |
|
636 | 636 | return formatter.mapfile_templatespec(b'changeset', mapfile, fp) |
@@ -1095,17 +1095,18 b' def open_template(name, templatepath=Non' | |||
|
1095 | 1095 | templatepath = templatedir() |
|
1096 | 1096 | if templatepath is not None or os.path.isabs(name): |
|
1097 | 1097 | f = os.path.join(templatepath, name) |
|
1098 | try: | |
|
1099 | 1098 |
|
|
1100 | except EnvironmentError: | |
|
1101 | return None, None | |
|
1102 | 1099 | else: |
|
1103 | 1100 | name_parts = pycompat.sysstr(name).split('/') |
|
1104 | 1101 | package_name = '.'.join(['mercurial', 'templates'] + name_parts[:-1]) |
|
1105 | try: | |
|
1106 | 1102 |
|
|
1107 | 1103 |
|
|
1108 | 1104 |
|
|
1109 | 1105 |
|
|
1110 | except (ImportError, OSError): | |
|
1106 | ||
|
1107 | ||
|
1108 | def try_open_template(name, templatepath=None): | |
|
1109 | try: | |
|
1110 | return open_template(name, templatepath) | |
|
1111 | except (EnvironmentError, ImportError): | |
|
1111 | 1112 |
|
General Comments 0
You need to be logged in to leave comments.
Login now