make --style=compact look for map-cmdline.compact.
authorVadim Gelfer <vadim.gelfer@gmail.com>
Sat, 04 Mar 2006 15:15:18 -0800
changeset 1914 a5bf0030df5f
parent 1913 74cf2b2f43d4
child 1915 9598cde4756d
make --style=compact look for map-cmdline.compact. change name of key in map file from changelog to changeset. rename command map files to start with map-cmdline. rename ui.logmap to ui.style in hgrc. now --style=foo does this: tries to open foo as file. tries as map-cmdline.foo in template path. tries as foo in template path.
doc/hgrc.5.txt
mercurial/commands.py
mercurial/templater.py
templates/map-cmdline.compact
templates/map-cmdline.default
templates/map-log.compact
templates/map-log.verbose
--- a/doc/hgrc.5.txt
+++ b/doc/hgrc.5.txt
@@ -240,8 +240,8 @@ ui::
     Allow to prompt the user.  True or False.  Default is True.
   logtemplate;;
     Template string for commands that print changesets.
-  logmap;;
-    Template map file for commands that print changesets.
+  style;;
+    Name of style to use for command output.
   merge;;
     The conflict resolution program to use during a manual merge.
     Default is "hgmerge".
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -349,7 +349,7 @@ class changeset_templater(object):
 
     def use_template(self, t):
         '''set template string to use'''
-        self.t.cache['changelog'] = t
+        self.t.cache['changeset'] = t
 
     def write(self, thing):
         '''write expanded template.
@@ -489,10 +489,10 @@ class changeset_templater(object):
             }
 
         try:
-            if self.ui.verbose and 'changelog_verbose' in self.t:
-                key = 'changelog_verbose'
+            if self.ui.verbose and 'changeset_verbose' in self.t:
+                key = 'changeset_verbose'
             else:
-                key = 'changelog'
+                key = 'changeset'
             self.write(self.t(key, **props))
         except KeyError, inst:
             raise util.Abort(_("%s: no key named '%s'") % (self.t.mapfile,
@@ -578,11 +578,12 @@ def show_changeset(ui, repo, opts):
     else:
         tmpl = ui.config('ui', 'logtemplate')
         if tmpl: tmpl = templater.parsestring(tmpl)
-    mapfile = opts.get('style') or ui.config('ui', 'logmap')
+    mapfile = opts.get('style') or ui.config('ui', 'style')
     if tmpl or mapfile:
         if mapfile:
             if not os.path.isfile(mapfile):
-                mapname = templater.templatepath(mapfile)
+                mapname = templater.templatepath('map-cmdline.' + mapfile)
+                if not mapname: mapname = templater.templatepath(mapfile)
                 if mapname: mapfile = mapname
         try:
             t = changeset_templater(ui, repo, mapfile)
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -76,9 +76,9 @@ class templater(object):
             return
         i = 0
         for l in file(mapfile):
-            l = l.rstrip('\r\n')
+            l = l.strip()
             i += 1
-            if l.startswith('#') or not l.strip(): continue
+            if not l or l[0] in '#;': continue
             m = re.match(r'([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.+)$', l)
             if m:
                 key, val = m.groups()
rename from templates/map-log.compact
rename to templates/map-cmdline.compact
--- a/templates/map-log.compact
+++ b/templates/map-cmdline.compact
@@ -1,4 +1,4 @@
-changelog = '{rev}{tags}{parents}   {node|short}   {date|isodate}   {author|user}\n  {desc|firstline|strip}\n\n'
+changeset = '{rev}{tags}{parents}   {node|short}   {date|isodate}   {author|user}\n  {desc|firstline|strip}\n\n'
 start_tags = '['
 tag = '{tag},'
 last_tag = '{tag}]'
rename from templates/map-log.verbose
rename to templates/map-cmdline.default
--- a/templates/map-log.verbose
+++ b/templates/map-cmdline.default
@@ -1,10 +1,12 @@
-changelog = 'changeset:   {rev}:{node}\n{tags}{parents}{manifest}user:        {author}\ndate:        {date|date}\nfiles:       {files}\n{file_adds}{file_dels}description:\n{desc|strip}\n\n\n'
+changeset = 'changeset:   {rev}:{node|short}\n{tags}{short_parents}user:        {author}\ndate:        {date|date}\nsummary:\n{desc|firstline}\n\n'
+changeset_verbose = 'changeset:   {rev}:{node}\n{tags}{parents}{manifest}user:        {author}\ndate:        {date|date}\nfiles:       {files}\n{file_adds}{file_dels}description:\n{desc|strip}\n\n\n'
 start_file_adds = 'files+:     '
 file_add = ' {file_add}'
 end_file_adds = '\n'
 start_file_dels = 'files-:     '
 file_del = ' {file_del}'
 end_file_dels = '\n'
+short_parent = 'parent:      {rev}:{node|short}\n'
 parent = 'parent:      {rev}:{node}\n'
 manifest = 'manifest:    {rev}:{node}\n'
 tag = 'tag:         {tag}\n'