Patchwork logstyle: Show the style list when I try to use a wrong one

login
register
mail settings
Submitter Iulian Stana
Date April 17, 2013, 3:43 p.m.
Message ID <98bcf83d70b195b64c0e.1366213438@doppler>
Download mbox | patch
Permalink /patch/1386/
State Changes Requested, archived
Headers show

Comments

Iulian Stana - April 17, 2013, 3:43 p.m.
# HG changeset patch
# User Iulian Stana <julian.stana@gmail.com>
# Date 1366213347 -10800
#      Wed Apr 17 18:42:27 2013 +0300
# Node ID 98bcf83d70b195b64c0ee3c901cd6780bacd806d
# Parent  186c1300c10d40b4d6871e851b57d8d44368dcb0
logstyle: Show the style list when I try to use a wrong one.

Patch

diff -r 186c1300c10d -r 98bcf83d70b1 mercurial/templater.py
--- a/mercurial/templater.py	Tue Apr 16 22:09:28 2013 +0300
+++ b/mercurial/templater.py	Wed Apr 17 18:42:27 2013 +0300
@@ -391,6 +391,16 @@ 
 
 engines = {'default': engine}
 
+def stylelist(mapfile):
+    path = "mercurial/templates"
+    dirlist =  os.listdir(path)
+    stylelist = 'the "%s" style is not found try: \n\n' % mapfile
+    for file in dirlist:
+        split = file.split(".")
+        if split[0] == "map-cmdline":
+            stylelist = stylelist + '\t' + split[1] + '\n'
+    return stylelist
+
 class templater(object):
 
     def __init__(self, mapfile, filters={}, defaults={}, cache={},
@@ -412,7 +422,8 @@ 
         if not mapfile:
             return
         if not os.path.exists(mapfile):
-            raise util.Abort(_('style not found: %s') % mapfile)
+            print stylelist(mapfile)
+            sys.exit()
 
         conf = config.config()
         conf.read(mapfile)