diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -1047,6 +1047,19 @@ def _readmapfile(mapfile): elif key == "__base__": # treat as a pointer to a base class for this style path = util.normpath(os.path.join(base, val)) + + # fallback check in template paths + if not os.path.exists(path): + for p in templatepaths(): + p2 = util.normpath(os.path.join(p, val)) + if os.path.isfile(p2): + path = p2 + break + p3 = util.normpath(os.path.join(p2, "map")) + if os.path.isfile(p3): + path = p3 + break + bcache, btmap = _readmapfile(path) for k in bcache: if k not in cache: diff --git a/tests/test-command-template.t b/tests/test-command-template.t --- a/tests/test-command-template.t +++ b/tests/test-command-template.t @@ -103,6 +103,18 @@ Test templates and style maps in files: $ hg log -l1 -T./map-simple 8 +Test template map inheritance + + $ echo "__base__ = map-cmdline.default" > map-simple + $ printf 'cset = "changeset: ***{rev}***\\n"\n' >> map-simple + $ hg log -l1 -T./map-simple + changeset: ***8*** + tag: tip + user: test + date: Wed Jan 01 10:01:00 2020 +0000 + summary: third + + Template should precede style option $ hg log -l1 --style default -T '{rev}\n'