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?
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
This one doesn't:
$ hg identify https://bitbucket.org/mg/git-talk; echo $?
abort: HTTP Error 404: Not Found
255
You'll probably want to redirect both stdout and stderr to /dev/null
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With