如何在我的网站上获得Bazaar版本的文件?

2024-05-13 15:00:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我以前也遇到过类似的问题。一个例子:How can I get the svn revision number in PHP?

但今天我要处理一个由BZR管理的项目。我需要得到一个特定文件的集市版本,并公布在我们的网站上的方式,它自动更新时,文件更新的数字。你知道吗

该网站是在Python所有,所以我愿意阅读幕后文件,但我更喜欢一个更被动的方法,如果可用。你知道吗


Tags: 文件the项目innumberget网站svn
3条回答

在Python中:

from bzrlib.branch import Branch
b = Branch.open(location_of_your_branch)
b.lock_read()
try:
    # Retrieve the contents of the last revision
    t = b.basis_tree()
    revid = t.get_file_revision(t.path2id(your_filename))
    print ".".join([str(x) for x in b.revision_id_to_dotted_revno(revid)])
finally:
    b.unlock()

一种方法是有一个脚本,推到您的网站,这个脚本的情况下更新版本.py或者类似的:

# update version
echo "VERSION = \"$(bzr revno)\"" > version.py
# push to website
rsync ...
# tag
bzr tag  force deployed-version

如果需要获取修改文件的最新版本,可以使用以下命令:

bzr log -l1  line <file> | cut -f1 -d:

相关问题 更多 >