mercurial/templater.py
changeset 45312 d9a502a0a9ca
parent 45311 3b27ed8e324e
child 45313 fef64d7a4a84
equal deleted inserted replaced
45311:3b27ed8e324e 45312:d9a502a0a9ca
   827     """Load template elements from the given map file"""
   827     """Load template elements from the given map file"""
   828     base = os.path.dirname(mapfile)
   828     base = os.path.dirname(mapfile)
   829     conf = config.config()
   829     conf = config.config()
   830 
   830 
   831     def include(rel, remap, sections):
   831     def include(rel, remap, sections):
   832         templatedirs = [base, templatedir()]
   832         subresource = None
   833         for dir in templatedirs:
   833         if base:
   834             if dir is None:
   834             abs = os.path.normpath(os.path.join(base, rel))
   835                 continue
       
   836             abs = os.path.normpath(os.path.join(dir, rel))
       
   837             if os.path.isfile(abs):
   835             if os.path.isfile(abs):
   838                 data = util.posixfile(abs, b'rb').read()
   836                 subresource = util.posixfile(abs, b'rb')
   839                 conf.parse(
   837         if not subresource:
   840                     abs, data, sections=sections, remap=remap, include=include
   838             dir = templatedir()
   841                 )
   839             if dir:
   842                 break
   840                 abs = os.path.normpath(os.path.join(dir, rel))
       
   841                 if os.path.isfile(abs):
       
   842                     subresource = util.posixfile(abs, b'rb')
       
   843         if subresource:
       
   844             data = subresource.read()
       
   845             conf.parse(
       
   846                 abs, data, sections=sections, remap=remap, include=include,
       
   847             )
   843 
   848 
   844     data = fp.read()
   849     data = fp.read()
   845     conf.parse(mapfile, data, remap={b'': b'templates'}, include=include)
   850     conf.parse(mapfile, data, remap={b'': b'templates'}, include=include)
   846 
   851 
   847     cache = {}
   852     cache = {}