自动更新带有水银的__version__吗? [英] automaticly update `__version__` with mercurial?

查看:90
本文介绍了自动更新带有水银的__version__吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何在PHP页面上显示hg信息库的当前工作副本版本

Possible Duplicate:
How to display current working copy version of an hg repository on a PHP page

类似于如何使用git重写python __version __?

,将自动更新的版本号存储在python文件中的最佳方法是什么?

Similar to How can I rewrite python __version__ with git?, what it is the best method to store an automatically updated version number inside a python file?

如何 Mercurial关键字计划,是否可以将版本号嵌入到应用程序中? 明确指出,自动更新$Revision$$Id$的svn样式方法不是可取的,而是由构建系统来代替.但是,这是python,没有构建系统,而这是一个完全包含在一个文件中的小程序,因此没有打包.

How good is my method of embedding version numbers into my application using Mercurial hooks? and the Mercurial keyword plan make it clear the svn-style method of automatically updating $Revision$ or $Id$ is not desirable and that the build system should do that work instead. This is python though, there is no build system and this is for a small program wholly contained in one file, so there is no packaging.

推荐答案

无论您使用哪种语言编写程序,都可以始终添加构建系统.您可能会说但是X语言不需要构建系统" ,但是这个问题表明确实如此:对于在发行任何版本之前需要完成的重复性任务,它都需要它.这些任务包括建立文档,运行测试以及将结果上传到某处.

You can always add a build system, no matter which language you write your program in. You might say "but language X doesn't need a build system", but this question shows that it does: it needs it for those repetitive tasks that needs to be done before any release. This is tasks like building the documentation, running tests, and uploading the result somewhere.

一个简单的Makefile或一个shell脚本就足够了:

A simple Makefile or a shell script is enough:

all: version

version:
    hg id > __version__

test: version
    @echo -n "running tests... "
    @sleep 1
    @echo " done."

doc: version
    @echo -n "building documentation... "
    @sleep 1
    @echo "done."

upload: test doc
    @echo -n "creating tarball... "
    @sleep 1
    @echo "done."
    @echo -n "publishing on website... "
    @sleep 1
    @echo "done."

.PHONY: version test upload doc

这篇关于自动更新带有水银的__version__吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆