0

I'm using hgweb to publish my local repositories.

/project_path/project_name/.hg/.hgrc have:

[hooks]
changegroup.bitbucket  =  hg push ssh://hg@bitbucket.org/user/repo

When i'm use hg serve, all changegroup hooks working fine, but when i'm using hgweb through nginx with fcgi it's not working at all. I need those functionality to have some kind of backups.

libbkmz
  • 641
  • 1
  • 7
  • 17
  • Backing up a bit this could be 'trust' as I'm suggesting below or 'auth' as daniel is suggesting. Either way there will be valuable, clear messages on stderr. Find where whever script container you're using with nginx is putting them and you'll probably have an obvious answer. Or just use Apache where the online walkthroughs would have had you up and running 24 hours ago. – Ry4an Brase Nov 27 '11 at 18:35

2 Answers2

2

It's mostly like Trust.

Mercurial needs to trust a hgrc file before it will parse/run it. If your /project_path/project_name/.hg/.hgrc file is owned by you then when you run hg serve with Mercurial running as you it's parsed/used. However, nginx runs as its own user, probably nginx which doesn't trust files owned by you, so when it invokes Mercurial those files are ignored (see Note).

That Mercurial trust link gives a better explanation and talks about how to say "nginx trusts X", but if it's a single-user system or you want everyone to trust you you can just throw a trust block in the system-global /etc/mercurial/hgrc file saying everyone trusts X.

Note: It doesn't actually just ignore those files it puts a warning on STDERR which in apache-land you'd find in your error.log, but in nginx land no one ever seems to find those warnings so I've no idea where nginx puts them.

Ry4an Brase
  • 78,112
  • 7
  • 148
  • 169
  • project .hgrc file owned by hg\hg. And nginx running by http user I add it to my /etc/mercurial/hgrc file like this: [trusted] users = hg, http groups = hg, http But nothing changed – libbkmz Nov 27 '11 at 06:19
  • Can you give an advice, how to read an stderr? Maybe without any hacks, just run manually hgweb script? Or anything else? – libbkmz Nov 27 '11 at 06:29
  • Sorry, I don't use nginx. You can test outputting something to stderr and look for it in your logs using a hook that does `echo FIND ME 2>&1`. When you run `hg --debug showconfig` from the command line do you see the trust settings you've added to `/etc/mercurial/hgrc`? If you do see them you've added them correctly and if you don't you haven't. – Ry4an Brase Nov 27 '11 at 18:29
0

I assume you have some kind of authentication issue here. When running hg serve from the command line, your ssh credentials are provided by an ssh-agent running in the background.

However, this does not work when running hgweb as a service, because there is no ssh-agent running in the background. If you would start an ssh-agent, there would be no possibility to enter the password for your ssh key.

Bitbucket uses ssh keys to authenticate you, so you can't just add your password to the above hg push command.

One possible solution would be to not use bitbucket as your backup, but a different mercurial server that let's you provide a simple password on the command line.

I'm afraid I can't help you further with this.

daniel kullmann
  • 13,653
  • 8
  • 51
  • 67
  • 1
    bitbucket supports https URLs and those do let you provide you password on the command line in the https://user:pass@host/path form that all HTTP auth honors. – Ry4an Brase Nov 27 '11 at 18:33