13

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.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
zerkms
  • 249,484
  • 69
  • 436
  • 539
  • mercurial-server is *not* Mercurial. It's not a part of Mercurial and it doesn't ship with Mercurial. It was not written by the authors of Mercurial. – Ry4an Brase May 05 '11 at 01:46
  • 1
    @Ry4an: thanks, captain. So what? )) and `2+2 = 4`. Any more obvious sentences in this thread? – zerkms May 05 '11 at 02:17
  • @zerkms Hold the phone... `2+2 = 4`? – alex May 05 '11 at 02:19
  • Just sayin' is all. The #mercurial channel, where most Mercurial support happens, gets tons of mercurial-server questions that no one can answer because no one uses mercurial server and somehow it got packaged on ubuntu. Rhodecode or hgweb are where it's at. When all three answers below (including the deleted one) misunderstood your question, it probably left something to be desired in the clarity department. – Ry4an Brase May 05 '11 at 02:27
  • @Ry4an: how is SO related to irc? I do know the difference and I do use gentoo (not ubuntu) )) And the fact that **2** of answerers did not get the question is because english is not my native and I cannot say properly. The 3rd answerer is an author of mercurial-server though ) – zerkms May 05 '11 at 02:29
  • The IRC reference was me showing why four different people might have assumed you didn't know that mercurial-server wasn't Mercurial -- because it's a very common misconception there and here. Congrats on using gentoo -- I'm sorry to hear they packaged that abomination too. – Ry4an Brase May 05 '11 at 02:32
  • @Ry4an: Why to sorry - it is a great tool to share repositories (in LAN). – zerkms May 05 '11 at 02:35
  • I've never seen that it does anything I want that hgweb doesn't do, and if I wanted more I'd use the much more capable Rhodecode. My primary beef is that they called it 'mercurial-server' when Mercurial already had a server, and confused hundreds of people who think they have to install that package to serve Mercurial repos, when the 'mercurial' package already had everything they needed. – Ry4an Brase May 05 '11 at 02:38
  • @Ry4an Nice to see that as is so often the case in the open source community, contribution is punished appropriately. :-) – Paul Crowley Feb 01 '12 at 16:25
  • 1
    I don't think there's a contribution being punished, but if I created a new project and named it "Paul Crowley's Nifty Software" and a lot of people asked you how to make it work you'd eventually get a little annoyed. :) – Ry4an Brase Feb 02 '12 at 17:40

2 Answers2

16

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.

Christophe Muller
  • 4,850
  • 1
  • 23
  • 31
  • Exactly. It is not obvious (at least for me) that it should be already created local repository, that we clone remotely. I thought all we need to do is to clone to the local *empty* dir new remote repo. – zerkms May 05 '11 at 12:48
  • *"Assuming that the path ... already exists"* Actually, the current version of Mercurial-server allows you to clone to the server even if the path hasn't been created previously. It is a very useful feature of Mercurial-server that... I'm still searching with Git :) – Christophe Muller Mar 17 '13 at 11:47
  • 1
    @Kangkan for cloning both ssh and http work on my server but for creating a repo, only ssh works for me. An attempt with http(s) gives me: `abort: cannot create new http repository`. – Christophe Muller Jun 23 '16 at 08:35
1

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.

RandomSF
  • 106
  • 2
  • Please read the section "Creating repositories" from that documentation link. It is specifically about creating remote repositories ;-) – zerkms May 04 '11 at 12:41