gpt4 book ai didi

python - hg verify 不返回 0 或 1

转载 作者:行者123 更新时间:2023-11-30 23:38:45 25 4
gpt4 key购买 nike

根据帮助

$ hg -v help verify
hg verify

verify the integrity of the repository

Verify the integrity of the current repository.

This will perform an extensive check of the repository's integrity,
validating the hashes and checksums of each entry in the changelog,
manifest, and tracked files, as well as the integrity of their crosslinks
and indices.

Returns 0 on success, 1 if errors are encountered.

控制台输出

>>> from subprocess import Popen, PIPE
>>> p = Popen(['hg', 'verify', '-R', 'sample-master'], stdout=PIPE, stdin=PIPE)
>>> out, err = p.communicate()
>>> out
'checking changesets\nchecking manifests\ncrosschecking files in changesets and manifests\nchecking files\n2186 files, 214 changesets, 3055 total revisions\n'
>>> err
>>> """-q is quite suppress output"""
>>> p = Popen(['hg', 'verify', '-R', 'sample-master', '-q'], stdout=PIPE, stdin=PIPE)
>>> out, err = p.communicate()
>>> out
''

我现在损坏了 .hg/store

>>> out, err = Popen(['hg', 'verify', '-R', 'sample-master', '-q'], stdout=PIPE, stdin=PIPE, stderr=PIPE).communicate()
>>> out, err
('', ' data/req.txt.i@119: missing revlog!\n 119: empty or missing req.txt\n req.txt@119: 8befed264a2f in manifests not found\n3 integrity errors encountered!\n(first damaged changeset appears to be 119)\n')

我没有看到 0 或 1。我错过了什么吗?

谢谢。

最佳答案

您正在寻找process return code :

p = Popen(['hg', 'verify', '-R', 'natrium-master', '-q'], stdout=PIPE, stdin=PIPE)
out, err = p.communicate()
print p.returncode

文档指的是exist status的过程。

关于python - hg verify 不返回 0 或 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14223062/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com