Bug 2395 - glog --style header and footer don't seem to work
Summary: glog --style header and footer don't seem to work
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-24 18:28 UTC by babert745
Modified: 2012-05-13 05:05 UTC (History)
3 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description babert745 2010-09-24 18:28 UTC
I was trying to create a custom .html style for glog and I could not get the 
header and footer tags to take (listed in /templates/template-vars.txt).  I 
noticed that the .xml style that comes with hg uses the header and footer 
tags, and the text is not output.  Run hg glog --style xml and compare with 
what is programed in /templtes/map-cmdline.xml.
Comment 1 kiilerix 2010-09-25 04:56 UTC
Can you be more specific - and perhaps provide a test case that shows the
problem and can be included in tests/test-glog.t (in default branch)?

It works fine with --style=compact and --style=changelog. It is not clear to
me how an xml output with semantic markup could work together with the
graphical rendering of graphlog.

I think that it is possible that graphlog templating can be extended to
cover your usecase if you can provide a good example of what you want and why.
Comment 2 babert745 2010-09-25 17:47 UTC
The default and compact styles that come with mercurial do not use the 
global header and footer tags (defined in /templates/template-vars.txt).  
The xml and changelog styles that come with mercurial use the global header 
tag and the xml style is the only one that uses the footer tag.   The bug is 
easy to replicate for the xml and changelog styles on any repository.  
Execute:

hg glog --style xml

Here is example output from running the above command: 

@  <logentry revision="0" node="1aa29fc031c7103673fb5d29e18e1e212398cb0a">
   <tag>tip</tag>
   <author email="bayes.law@gmail.com">babert745</author>
   <date>2010-09-24T19:58:09-04:00</date>
   <msg xml:space="preserve">Test</msg>
   </logentry>

My understanding based on reading /templates/template-vars.txt and 
/templates/map-cmdline.xml is that the output should be:

<?xml version="1.0"?>
<log>
@  <logentry revision="0" node="1aa29fc031c7103673fb5d29e18e1e212398cb0a">
   <tag>tip</tag>
   <author email="bayes.law@gmail.com">babert745</author>
   <date>2010-09-24T19:58:09-04:00</date>
   <msg xml:space="preserve">Test</msg>
   </logentry>
</log>

The difference is that the actual output is missing the header and footer 
defined in /templates/map-cmdline.xml as

header = '<?xml version="1.0"?>\n<log>\n'
footer = '</log>\n'

Let me know if this is not specific enough.

I am sure the template option is a more powerful feature.  But simplicity is 
powerful too, all I need to do is wrap the glog with a simple html header 
and footer.  I don't know how to add a test case in the tests/test-glog.t, 
but I will try and look into it.
Comment 3 kiilerix 2010-09-25 18:57 UTC
Ok, so you _just_ want header and footer around the glog output - probably
in order to wrap it in pre tags?

Can you verify if that is achieved by this patch:

--- a/hgext/graphlog.py
+++ b/hgext/graphlog.py
@@ -229,7 +229,9 @@
         char = ctx.node() in showparents and '@' or 'o'
         displayer.show(ctx)
         lines = displayer.hunk.pop(rev).split('\n')[:-1]
+        displayer.flush(rev) # write header
         ascii(ui, state, type, char, lines, edgefn(seen, rev, parents))
+    displayer.close() # write footer
 
 def graphlog(ui, repo, path=None, **opts):
     """show revision history alongside an ASCII revision graph
Comment 4 babert745 2010-09-26 07:44 UTC
Yep, I want to wrap the output in pre tags and add a java script call.  

I tested the patch and it works great. 

hg glog --style xml 

now includes the header and footer specified in /templates/map-cmdline.xml.  
Not sure where to go from here, will you push the patch to the production 
code repository for inclusion in the next release or is there a more formal 
process?
Comment 5 kiilerix 2010-09-26 15:29 UTC
Do the patch also solve your _real_ problem?

(glog with style xml obviously doesn't make any sense at all.)
Comment 6 babert745 2010-09-26 18:24 UTC
Sure did.  Thanks a bunch.
Comment 7 HG Bot 2010-09-27 20:00 UTC
Fixed by http://hg.intevation.org/mercurial/crew/rev/aa1faedeac5a
Mads Kiilerich <mads@kiilerich.com>
graphlog: style with header and footer (issue2395)
Comment 8 Bugzilla 2012-05-12 09:12 UTC

--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:12 EDT  ---

This bug was previously known as _bug_ 2395 at http://mercurial.selenic.com/bts/issue2395