获取bazaar中的文件大小

发布于 2024-09-05 21:36:58 字数 103 浏览 1 评论 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悍妇囚夫 2024-09-12 21:36:58

您无法从命令行获取有关文件大小的信息,但可以通过 python 使用 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()

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()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文