# HG changeset patch # User Iulian Stana # Date 1367544194 18000 # Node ID 6ba6e345961e9844c0f97247a091a2daeddf5ba2 # Parent 4cdec37f0018e361e8159632ec5afeb705c433b1 templater: show the style list when I try to use a wrong one When someone try to use a wrong style, a list with sugestions will appear. In the test-log.t file it's a test that prove this thing. diff -r 4cdec37f0018 -r 6ba6e345961e mercurial/templater.py --- a/mercurial/templater.py Sat Apr 27 23:49:34 2013 -0700 +++ b/mercurial/templater.py Thu May 02 20:23:14 2013 -0500 @@ -394,6 +394,16 @@ engines = {'default': engine} +def stylelist(): + path = templatepath()[0] + dirlist = os.listdir(path) + stylelist = [] + for file in dirlist: + split = file.split(".") + if split[0] == "map-cmdline": + stylelist.append(split[1]) + return ", ".join(stylelist) + class templater(object): def __init__(self, mapfile, filters={}, defaults={}, cache={}, @@ -415,7 +425,8 @@ if not mapfile: return if not os.path.exists(mapfile): - raise util.Abort(_('style not found: %s') % mapfile) + raise util.Abort(_("style '%s' not found") % mapfile, + hint=_("available styles: %s") % stylelist()) conf = config.config() conf.read(mapfile) diff -r 4cdec37f0018 -r 6ba6e345961e tests/test-log.t --- a/tests/test-log.t Sat Apr 27 23:49:34 2013 -0700 +++ b/tests/test-log.t Thu May 02 20:23:14 2013 -0500 @@ -84,6 +84,14 @@ abort: cannot follow file not in parent revision: "dir" [255] +-f, a wrong style + + $ hg log -f -l1 --style something + abort: style 'something' not found + (available styles: changelog, bisect, default, xml, compact) + [255] + + -f, but no args $ hg log -f