2013년 12월 4일 수요일

Mercurial - remote: abort: There is no Mercurial repository here (.hg not found)!

I am a newbie to Mercurial and had some troubles cloning my own repository via ssh.
The error messages I got are:

remote: abort: There is no Mercurial repository here (.hg not found)!
abort: no suitable response from remote hg!

The command I used is:

hg clone ssh://user@hostname/absolute/path/to/the/repository

The thing is, although the error messages above say that I gave it a wrong path name, actually, I didn't. This can be proved by the following code working fine:

ssh user@hostname 'ls /absolute/path/to/the/repository'

After some googling, I found out from here that an absolute path given to Mercurial should start with '//', not with '/'.
So the following code works fine:

hg clone ssh://user@hostname//absolute/path/to/the/repository
Note that there are two '/'s between hostname and absolute.

If you want your source-path to be a relative path from the $HOME environment variable, it starts with '/', not with '//', as the following:

hg clone ssh://user@hostname/relative/path/to/the/repository

c.f.
It's rather confusing that different tools use different notations for the source path, when accessing remote resources via ssh.
For example, Subversion uses an absolute path that starts with '/':
In the case of scp, it goes like this (It uses a relative path w.r.t. $HOME environment variable. Not that the path starts with ':', not with '/'.):

scp user@hostname:relative/path/to/the/source/file path/to/the/destination

댓글 없음:

댓글 쓰기