Algo como isso deve fazer o truque:
#!/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)
Uso:
python diff-from-tagged.py test
Saída:
=== 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