Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if a url is a mercurial repository (like git ls-remote)

Tags:

mercurial

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?

like image 801
Jakob Malm Avatar asked Apr 22 '13 11:04

Jakob Malm


1 Answers

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.

like image 89
Martin Geisler Avatar answered Nov 03 '22 11:11

Martin Geisler