I am using the following code to detect if the folder .hg exists in the current directory. If it doesn’t, then the function returns:
if [ ! -d ".hg" ]; then
return
fi
How can I modify this to check if .hg exists either in the current directory or in a parent / ancestor directory? I’d imagine if it isn’t an option such as -d then the solution is going to be recursive.
I’d just cheat on this one:
hg statusshould be successful as long as you are somewhere inside a mercurial tree.