Creating new repositories using mercurial-server

13.6k views Asked by At

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.

2

There are 2 answers

3
Christophe Muller On BEST ANSWER

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.

1
RandomSF On

The page you reference is for sharing existing repositories, not specifically for creating new, empty ones. The command you give hg init tst is correct for initializing a new, empty repository. I think the only 'inelegant' thing about it is that you are doing it remotely and thus need to give the additional ssh commands. The repository creation command itself hg init is quite simple.