Hglib: How to connect to remote repo using over ssh?

749 views Asked by At

Using "raw" mercurial API I can write just something like:

peer = hg.peer(ui.ui(), {}, 'ssh://[email protected]/some/project')

After the connection is established, I can work with remote repo.

I'm failing to understand what should work with a remote repo using hglib. Naïve approach, i.e. using something just as simple as:

hglib.open("ssh://[email protected]/some/project")

does not work, and the exception raised does not make anything clearer to me.

My question: With hglib, how can I open connection to a remote ssh-repo?

1

There are 1 answers

0
fritzvd On

The hglib documentation is not very wordy about how to use it. The best is to already have your key copied and RSA fingerprint in your ~/.ssh/known_hosts.

But you can clone a repo with:

hglib.clone(source="ssh://[email protected]/some/project")

You can of course add destination folder (e.g. dest="/path/to/blah").

If you already have an existing hg repo cloned you can change some settings in your hgrc before trying hglib.open(), so hg uses the ssh url like so:

[ui]
username = some_user

[paths]
default = ssh://[email protected]/some/project

EDIT I think for hg.open to work, you have to have a repo checked out. For me I refer to the path where my repo is cloned. So:

hglib.open('/path/to/cloned/repo')

To do this over SSH you have to edit your /repopath/.hg/hgrc as mentioned above.