How to make the Mercurial (hgwebdir) rss/atom feed display the branch name

纵饮孤独 提交于 2019-12-05 18:27:48

Installation locations differ, but on ubuntu you'll find the relevant file as /usr/share/mercurial/templates/atom/changelogentry.tmpl.

It starts out looking like:

 <entry>
  <title>{desc|strip|firstline|strip|escape|nonempty}</title>
  <id>{urlbase}{url}#changeset-{node}</id>
  <link href="{urlbase}{url}rev/{node|short}"/>
  <author>
   <name>{author|person|escape}</name>
   <email>{author|email|obfuscate}</email>
      </author>
  <updated>{date|rfc3339date}</updated>
  <published>{date|rfc3339date}</published>
  <content type="xhtml">
   <div xmlns="http://www.w3.org/1999/xhtml">
    <pre xml:space="preserve">{desc|escape|nonempty}</pre>
   </div>
  </content>
 </entry>

and you can add anything you find in hg help templates including:

branches    String. The name of the branch on which the changeset was committed. Will be
            empty if the branch name was default.

I finally found a solution on the Mercurial mailing lists.

I had to edit templates\rss-log\changelogentry.tmpl like this:

<item>
  <title>{desc|strip|firstline|strip|escape}</title>
  <guid isPermaLink="true">{urlbase}{url}rev/{node|short}</guid>
  <description>
    <![CDATA[<i>{inbranch%branchname}{branches%branchname}</i>
    <p>{desc|strip|escape|addbreaks|nonempty}]]>
  </description>
  <files>{file_mods}</files>
  <author>{author|obfuscate}</author>
  <pubDate>{date|rfc822date}</pubDate>
</item>

And I had to add the following line to templates\rss-log\map:

branchname = '{name}'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!