Joy
Joy

Reputation: 9550

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

all,

I have searched for this problem for long time and tried different methods.

I want to maintain my code on the server through only SSH. But when I run this:

sudo hg clone -v ssh://carl@hostname//home/carl/Java/Projects/peta/

Mercurial keeps telling me remote: abort: There is no Mercurial repository here (.hg not found)!. Some articles said that the path should be correct and there should be a .hg directory there. But I have checked it for several times and I am sure there is a .hg folder at the right place.

I also tried

hg --config ui.remotecmd=/usr/bin/hg clone ssh://carl@hostname//home/carl/Java/Projects/peta/

But it failed as well. What other problem it could be? Thanks.


Solved

I finally fix the problem. Previously, I create a repository on my local machine, and scp all files (including .hg) on to the server. I try to remove .hg directory first, and create a repo on the server through ssh (hg init). Then hg clone works!

Upvotes: 18

Views: 23153

Answers (4)

Vladius
Vladius

Reputation: 4817

Running on Debian, to solve my problem, I have added the following line to my /var/lib/mercurial-server/.mercurial-server configuration file after the [paths]

[paths]
/ = ~/repos
...

And don't forget to issue this command afterwards: sudo -u hg /usr/share/mercurial-server/refresh-auth

Upvotes: 0

Ray
Ray

Reputation: 5659

César Bustíos's answer is almost correct, but that tries to clone from remote to local. To opposite way, we have to add the local path. In the case it is the current directory, it will be a dot.

hg clone . ssh://USER@REMOTE/path/to/repo

Hope it helps. :)

Upvotes: 0

Lazy Badger
Lazy Badger

Reputation: 97270

Extraction from hg help urls

Some notes about using SSH with Mercurial:

  • SSH requires an accessible shell account on the destination machine and a copy of hg in the remote path or specified with as remotecmd.
  • path is relative to the remote user's home directory by default. Use an extra slash at the start of a path to specify an absolute path:

    ssh://example.com//tmp/repository

this means, at least, that you can't use the same URI and change only one/two slash it it: at least one path will be non-existent.

Consequence of the quote and error message: you must to debug (with any ssh-tool) and find correct path to needed directory. you can:

  • use scp (f.e) and copy known file from known location
  • SSH into remote host in interactive session and verify path (both?) by hand, i.e: ssh ..., cd ..., pwd, verify output of pwd
  • ... any other debugger

When you'll get good path after login, you have to check next point of failure - .hg dir permissions

After verification of these checkpoints you'll get clone and some bonus in the form of understanding "What happened before"

HTH

Upvotes: 30

César
César

Reputation: 10109

I don't know if this really helps but, according to the FAQ:

hg clone ssh://USER@REMOTE/path/to/repo

They are using only one / after the USER@HOST. Maybe you can try that way.

Upvotes: 1

Related Questions