3
# USAGE: blame.py [-r REV] repos-path file
10
from svn import fs, core, repos
14
def getfile(pool, path, filename, rev=None):
20
repos_ptr = repos.open(path, pool)
21
fsob = repos.fs(repos_ptr)
24
rev = fs.youngest_rev(fsob, pool)
26
for i in xrange(0, rev+1):
27
root = fs.revision_root(fsob, i, pool)
28
if fs.check_path(root, filename, pool) != core.svn_node_none:
31
print "First revision is %d" % first
32
print "Last revision is %d" % rev
33
for i in xrange(first, rev+1):
35
root = fs.revision_root(fsob, i, pool)
37
if not fs.contents_changed(root, filename, previousroot, filename, pool):
40
file = fs.file_contents(root, filename, pool)
41
previousdata = filedata
44
data = core.svn_stream_read(file, CHUNK_SIZE)
47
filedata = filedata + data
49
print "Current revision is %d" % i
50
diffresult = difflib.ndiff(previousdata.splitlines(1),
51
filedata.splitlines(1))
52
# print ''.join(diffresult)
56
if annotresult.has_key (k):
60
annotresult[k] = (i, j[2:])
65
annotresult[k] = (i, j[2:])
68
# print ''.join(diffresult)
70
for x in xrange(len(annotresult.keys())):
71
sys.stdout.write("Line %d (rev %d):%s" % (x,
76
print "USAGE: blame.py [-r REV] repos-path file"
80
opts, args = getopt.getopt(sys.argv[1:], 'r:')
84
for name, value in opts:
87
core.run_app(getfile, args[0], args[1], rev)
89
if __name__ == '__main__':