0

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.

NawaMan
  • 25,129
  • 10
  • 51
  • 77

1 Answers1

1

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
  • 20,053
  • 8
  • 46
  • 63