Search code examples
mercurialmercurial-server

Creating new repositories using mercurial-server


According to the "Creating repositories" at http://dev.lshift.net/paul/mercurial-server/docbook.html all we need to do to create new repository - is to clone not existent one.

But in 1.1 I doesn't work. And if we look at code:

if cmd is None:
    fail("direct logins on the hg account prohibited")
elif cmd.startswith('hg -R ') and cmd.endswith(' serve --stdio'):
    repo = getrepo("read", cmd[6:-14])
    if not os.path.isdir(repo + "/.hg"):
        fail("no such repository %s" % repo)
    dispatch.dispatch(['-R', repo, 'serve', '--stdio'])
elif cmd.startswith('hg init '):
    repo = getrepo("init", cmd[8:])
    if os.path.exists(repo):
        fail("%s exists" % repo)
    d = os.path.dirname(repo)
    if d != "" and not os.path.isdir(d):
        os.makedirs(d)
    dispatch.dispatch(['init', repo])
else:
    fail("illegal command %r" % cmd)

we can see, that to create we need to pass specifically init command.

This command works as expected:

"TortoisePlink.exe" -ssh -2 hg@mercurial "hg init tst"

but I hope it is some more elegant command to do so.

Well, is it a "bug" in documentation or am I doing something wrong?

UPDATE:

My question is only about creating repositories remotely using mercurial-server.

UPDATE 2:

It was my misunderstanding, since it was not clear for me that there should be already created local repository, that will be cloned remotely.


Solution

  • I find it very straightforward to create a new repo using Mercurial-server. Assuming that you have the rights and that the path "/dir1/dir2/" already exist on the server, simply (using command line):

    mkdir new
    cd new
    hg init
    hg clone . ssh://hg@server/dir1/dir2/new
    

    Cheers,
    Christophe.