Is it possible to clone and create a new repo?

497 views
Skip to first unread message

mbrownnyc

unread,
Jan 11, 2012, 4:09:32 PM1/11/12
to rhodecode
Hello,

I've little experience with mercurial, enough for me to be dangerous.

After reading some docs, cloning repos to https:// destinations seems
pretty clear.

However, when I attempt to clone to a new repo, I receive an error:

hg clone . https://mbrown@server/rhodecode/testrepo
abort: cannot create new http repository

However, if I create a repo in the web UI of rhodecode I have no
problem cloning using the same syntax.


Is it possible to create a new repo from the hg command-line towards
the rhodecode server?


Thanks,

Matt

Matt Zuba

unread,
Jan 11, 2012, 5:58:09 PM1/11/12
to rhod...@googlegroups.com
The middleware layer of rhodecode for Mercurial does not support such an action.

mbrownnyc

unread,
Jan 11, 2012, 9:37:40 PM1/11/12
to rhodecode
Thanks Matt.

Is there another way to create a repo from the hg command line?

If not, is this planned for the future?


Thanks,

Matt

Marcin Kuzminski

unread,
Jan 11, 2012, 10:28:11 PM1/11/12
to rhod...@googlegroups.com
Repositories can be created from command line using RhodeCode API please read this: http://packages.python.org/RhodeCode/api/api.html#create-repo
It can be done with simple curl command.

mbrownnyc

unread,
Jan 12, 2012, 10:24:07 AM1/12/12
to rhodecode
Thanks Marcin.

I'll present this as a solution.

I'm looking to migrate a bunch of existing repos that were previously
server over CIFS/SMB. This is what the devs are used to, and hg
clones and hg inits to a file system are no problem. I don't foresee
this extra layer (when provided with a script for the API calls) to
cause much issue.


Thanks!

Matt

mbrownnyc

unread,
Jan 12, 2012, 10:33:42 AM1/12/12
to rhodecode
One last question, Marcin:

Is it possible to reveal the API key of a user who curls a page at run
time?

For instance:

curl https://mbrown@server/rhodecode/_admin/apikey


That way it would be possible to obtain the apikey via a script to
populate the POST.


Thanks,

Matt

mbrownnyc

unread,
Jan 12, 2012, 1:50:50 PM1/12/12
to rhodecode
Also, the docs are confusing for create_repo:

api_key : "<api_key>"
method : "create_repo"
args: {
"name" : "<name>",
"owner_name" : "<ownername>",
"description" : "<description> = ''",
"repo_type" : "<type> = 'hg'",
"private" : "<bool> = False"
}


Should be:
"
api_key : "<api_key>"
method : "create_repo"
args: {
"name" : "<name>",
"owner_name" : "<ownername>",
"description" : "<description> = ''",
"repo_type" : "<repo_type>",
"private" : "<bool>"
}

repo_type allowed aliases are 'git', 'hg'
bool is either 0 or 1, not false or true.


Thanks,

Matt


On Jan 12, 10:33 am, mbrownnyc <matthewbr...@gmail.com> wrote:
> One last question, Marcin:
>
> Is it possible to reveal the API key of a user who curls a page at run
> time?
>
> For instance:
>
> curlhttps://mbrown@server/rhodecode/_admin/apikey

mbrownnyc

unread,
Jan 12, 2012, 1:57:58 PM1/12/12
to rhodecode
One more problem:

It appears that I can not clone an existing repo to the repo created
with the API:

I run:

| curl --insecure https://server/rhodecode/_admin/api -X POST -H
'content-type:text/plain' --data-binary '[MY API
KEY]","method":"create_repo","args":
{"name":"testrepo","owner_name":"mbrown","description":"'This\ is\ a\
test\ repo'","repo_type":"'hg'","private":"0"}}'

Then navigate to the directory of an existing repo and type:

| hg clone . https://mbrown@server/rhodecode/testrepo

I receive: "abort: cannot create new http repository"


I do not have this problem when I create the repo through the
rhodecode web UI.


Thanks,

Matt

Matt Zuba

unread,
Jan 12, 2012, 4:38:01 PM1/12/12
to rhod...@googlegroups.com
You wouldn't want to clone to the new repo, you'd want to push to the new repo... hg push https://mbrown@server/rhodecode/testrepo

What you are attempting to do is a limitation of Mercurial itself, not Rhodecode.  Mercurial does not natively support creating remote repositories:

From httprepo.py:
def instance(ui, path, create):
    if create:
        raise util.Abort(_('cannot create new http repository'))

Marcin Kuzminski

unread,
Jan 12, 2012, 8:12:34 PM1/12/12
to rhod...@googlegroups.com
No that would be very insecure, api_key is like password.
If you feel like there's a method for get_user you can extend it to return the api_key.

mbrownnyc

unread,
Jan 13, 2012, 10:10:07 AM1/13/12
to rhodecode
Thanks Matt for the info.

Marcin: I guess I'm asking what type of authentication mechanism is
present to auth to the web pages anyway? basic, ntlm, digest, or
negotiate? After authentication with a user, producing a plain text
page populated with that user's API key isn't insecure.
Reply all
Reply to author
Forward
0 new messages