如何检查 URL 是否指向 mercurial 存储库?使用 git,我会使用 git ls-remote $url
并检查返回值。 hg 有类似的东西吗?
最佳答案
您可以使用 hg identify
为此:它可以针对远程存储库运行,如果给定的路径不是存储库,Mercurial 将中止并退出代码为 255。此存储库存在:
$ hg identify https://bitbucket.org/mg/mercurial-talk; echo $?
7788b512c5bd
0
这个没有:
$ hg identify https://bitbucket.org/mg/git-talk; echo $?
abort: HTTP Error 404: Not Found
255
您可能希望将 stdout 和 stderr 都重定向到
/dev/null
.
关于mercurial - 检查 url 是否是 mercurial 存储库(如 git ls-remote),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16145854/