【问题标题】:Fastest way to know the status of mercurial repo了解 mercurial repo 状态的最快方法
【发布时间】:2016-11-06 17:46:48
【问题描述】:

在大型存储库上,hg status 可能会非常慢,如果我们想在 shell 提示符中显示存储库的状态,这可能是个问题。

这是hg --profile status的结果:

   CallCount    Recursive     Total(s)    Inline(s) module:lineno(function)
        7682            0      0.3287      0.3287   <mercurial.osutil.listdir>
       63067            0      0.2052      0.2052   <method 'match' of '_sre.SRE_Pattern' objects>
           1            0      0.7164      0.0735   mercurial.dirstate:999(traverse)
           2            0      0.8105      0.0496   mercurial.dirstate:1102(status)
         139            0      0.0420      0.0420   <zlib.decompress>
       62501            0      0.1137      0.0339   mercurial.dirstate:617(_normalizefile)
          12            0      0.0307      0.0307   <method 'read' of 'file' objects>
       63760            0      0.0283      0.0283   <method 'get' of 'dict' objects>
           1            0      0.0217      0.0217   <mercurial.parsers.make_file_foldmap>
         376            0      0.0508      0.0202   mercurial.manifest:468(walk)
       70079            0      0.0327      0.0170   mercurial.posix:241(normcase)
           1            0      0.0167      0.0167   mercurial.dirstate:200(_dirs)
       70079            0      0.0156      0.0156   <mercurial.parsers.asciilower>
           2            0      0.0137      0.0137   <mercurial.parsers.parse_dirstate>
       62875            0      0.2166      0.0116   mercurial.match:177(__call__)
           4            0      0.0113      0.0113   <method 'update' of '_hashlib.HASH' objects>
           1            0      0.0107      0.0106   mercurial.manifest:451(_dirs)
         105           75      0.0132      0.0081   <__import__>
           2            0      0.7559      0.0069   mercurial.dirstate:940(walk)
           2            0      0.0062      0.0062   <mercurial.mpatch.patches>
         724          678      0.0188      0.0061   sre_parse:395(_parse)
        1198         1152      0.0094      0.0056   sre_compile:64(_compile)
        3866            0      0.0043      0.0040   re:208(escape)
        6227            0      0.0044      0.0036   sre_parse:193(__next)
           1            0      0.0767      0.0028   mercurial.manifest:1307(read)
        1431         1152      0.0032      0.0026   sre_parse:151(getwidth)
           1            0      0.0219      0.0026   mercurial.dirstate:167(_dirfoldmap)
       30130            0      0.0024      0.0024   <method 'append' of 'list' objects>
           1            0      0.0022      0.0022   mercurial.manifest:407(__init__)
        7573            0      0.0036      0.0022   sre_parse:141(__getitem__)

我已经找到了针对 hg branch (see here for more details) 的优化,但我找不到针对 hg status 的优化。

你知道一些改善这一点的魔术吗?我不需要知道哪些文件是脏文件的详细信息,我只需要知道 repo 是否干净,这样我就可以显示干净或红色的提示。

谢谢!

【问题讨论】:

    标签: shell mercurial sh


    【解决方案1】:

    您是否尝试过FsMonitor 扩展程序?

    维基页面的描述:

    将文件监控程序 Watchman 与 Mercurial 集成到 产生更快的状态结果。

    在特定的 Linux 系统上,对于具有超过 在 ext4 上托管 400,000 个文件,vanilla hg 状态需要 1.3 秒。在 同一个系统,使用 fsmonitor 大约需要 0.3 秒。

    【讨论】:

    • 这看起来很有希望,直到我读到这个:fsmonitor will disable itself if any of the following extensions are enabled: largefiles,我们在我们的项目中使用它:(但是谢谢,对于任何其他情况,这似乎是一个很好的扩展!
    • @Creak,我强烈建议您将大文件存储库转换为普通存储库并使用 FsMonitor。我做到了,我被震撼了。查看我的回答stackoverflow.com/a/39365416/561422 了解更多详情。
    • @marco.m 恐怕我做不到。我不是存储库的所有者 :(
    猜你喜欢
    • 1970-01-01
    • 2017-11-14
    • 1970-01-01
    • 2014-01-28
    • 1970-01-01
    • 2020-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多