? Two issues creating a style for 'hg log'

Jens Alfke jens at mooseyard.com
Wed Jul 25 12:39:50 CDT 2007


Hi! I'm a fairly new convert to Mercurial. I'm making a style for "hg  
log" that outputs XML, to make it easily parseable by a program I'm  
writing that calls Mercurial under the hood. It works fine except for  
two issues:

(1) The header gets generated, but not the footer. This prevents the  
output from being correct XML.
(2) The "file_add" and "file_del" macros never get invoked, so all  
changed paths are output the same way. This prevents my app from being  
able to tell whether a given file was modified, added or removed by a  
changeset.

I'm using Mercurial 0.9.4 on Mac OS X with Python 2.5.1.
Below are the two files that make up the style.

--Jens

PS: This seems like something someone might have built already ... if  
so, please let me know!

# File xml.style
header = '<?xml version="1.0" encoding="UTF-8" ?>\n<repository  
name="{repo}">\n\n'
footer = '</repository>\n'
changeset = changeset.tmpl
start_files = '    <files>\n'
file     = '\t<file path="{file|escape}" />\n'
file_add = '\t<file path="{file|escape}" mode="add" />\n'
file_del = '\t<file path="{file|escape}" mode="del" />\n'
file_copy= '\t<file path="{file|escape}" mode="copy" src="{source}" /> 
\n'
end_files = '    </files>\n'
parent = '    <parent rev="{rev}" />\n'
branch = '    <branch name="{branch|escape}" />\n'
tag    = '    <tag name="{tag|escape}" />\n'
extra  = '    <extra key="{key|escape}" value="{value|escape}" />\n'

# File changeset.tmpl
<changeset rev="{rev}" node="{node|escape}" date="{date|isodate| 
escape}">
{parents}{branches}{tags}
     <author name="{author|person|escape}" email="{author|email| 
escape}" />
     <description>{desc|strip|escape}</description>
{files}{file_adds}{file_dels}{file_copies}
</changeset>




More information about the Mercurial mailing list