检查网址是否是Mercurial存储库(例如git ls-remote) [英] Check if a url is a mercurial repository (like git ls-remote)

查看:109
本文介绍了检查网址是否是Mercurial存储库(例如git ls-remote)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查URL是否指向商品库?使用git时,我将使用git ls-remote $url并检查返回值.汞有类似的东西吗?

How can I check whether a URL points to a mercurial repository? With git, I would use git ls-remote $url and check the return value. Is there something similar for hg?

推荐答案

您可以为此使用hg identify:它可以在远程存储库上运行,如果给定的路径不是'Mercurial,则退出代码为255'. t存储库.该存储库存在:

You can use hg identify for this: it can be run against a remote repository and Mercurial will abort with an exit code of 255 if the path given isn't a repository. This repository exists:

$ 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.

You'll probably want to redirect both stdout and stderr to /dev/null.

这篇关于检查网址是否是Mercurial存储库(例如git ls-remote)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆