What is the best way to include Mercurial changeset id (or revision) in a Django template?
I am developing a Django site and am using hg for revision control. I would like to embed the changeset id to the footer of the site like Stackoverflow and Bitbucket do in their footer. What is the best way to accomplish this?
Do I have to use the Mercurial api? Is there a way to get hg form the CLI to output just the revision id so I 开发者_如何学JAVAcan capture that in my deployment scripts and just include the simple text output in the template?
Methods you have used would be appreciated. Thanks
See: KeywordPlan
In your release-to-production process, use hg id
to get the current version information from Mercurial. You can easily stash that in a file that you then include in your Django templates.
For example, in whatever script/process you use at release time, do:
hg id >templates/id.html
And then at the bottom in your main Django template (or wherever), add:
Revision: {{ include "templates/id.html" }}
(NOTE: the paths/directories may vary depending on how you have your template paths configured in Django).
精彩评论