只有在mercuri中有任何更改时才运行commit

2024-10-02 02:35:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我和一个问这个问题的人有同样的问题:How to git commit nothing without an error? 基本上,我需要运行hgcommit,只有在我的存储库中有任何更改的情况下。我使用fabric运行提交,因此如果没有任何更改,它将输出一个严重的错误。在

local() encountered an error (return code 1) while executing 'hg commit...'

这是上述帖子的答案:

^{pr2}$

它适用于git,但是我使用Merucrial。我不知道在Mercurial怎么做。在


Tags: togitanreturnlocal错误情况error
2条回答

从泰勒·艾夫斯(Tyler Eaves)在你的问题链接页面上的回答(不知道面料),你能做以下事情:

with hide('warnings'):
  with settings(warn_only=True):
    run('hg commit -q ...')

如果没有文件,就不会提交报告。它也不会报告是否有已提交的文件,这可能不是您想要的:)

因此,正如koopajah和Kent在评论中建议的那样,我可以使用hg status或{}的输出来查看是否有任何更改。 Fabric允许我读取带有capture=True标志的输出。在

if local('hg status', capture=True):
    local('hg commit')

很直接。在

相关问题 更多 >

    热门问题