tags:

views:

32

answers:

1

Hi all. How can I get the size of a versioned file/files? This seems to be a very common operation but I can't find how (Am I missing something?). Well, I can get it indirectly by catting it and count the bytes but this is very slow.

Any help would be appropriated.

+1  A: 

You can't get information about file size from command-line but can get it with python, using bzrlib.

 import bzrlib
 from bzrlib import branch

 b = branch.Branch.open('.')
 b.lock_read()
 try:
     rt = b.repository.revision_tree(revision_id)
     fileid = rt.path2id('filename')
     if fileid is None:
         print 'file is not versioned!'
     else:
         print 'file size:', rt.get_file_size(fileid)
finally:
    b.unlock()
bialix
Thank you very much. This is very useful.
NawaMan