我有一个使用 bzr 跟踪的文件,我想编写脚本,在它的当前(当前为当前,而不是最新提交)和标记为 的最新提交版本之间创建差异。
有谁知道如何做到这一点?不是 bzr 脚本或 Python 专家。
像这样的事情应该可以解决问题:
#!/usr/bin/env python
import commands
import sys
import os
# Get the revision number of the most recent tagged commit.
tags = commands.getoutput("bzr tags --sort=time")
latest = tags.split()[-1]
target = sys.argv[-1]
if not os.path.isfile(target):
print "Error, no such file: '"+target+"'"
sys.exit(1)
print commands.getoutput("bzr diff "+target+" -r "+latest)
Run Code Online (Sandbox Code Playgroud)
用法:
python diff-from-tagged.py test
Run Code Online (Sandbox Code Playgroud)
输出:
=== modified file 'test'
--- test 2011-01-08 19:20:31 +0000
+++ test 2011-01-08 20:00:12 +0000
@@ -1,1 +1,2 @@
dfsafd
+The quick brown fox
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
283 次 |
最近记录: |