48

I'm having problems with pushing to mercurial repository:

$ hg push
pushing to https://user:***@hg.domain.com/X_repo
searching for changes
abort: authorization failed

The same URL (with the same credentials) is accessible through the web browser. Also, I tried it without embedding usr+pass into the URL.

HTTPS is correctly configured, I tried both Basic and Digest auth -- without a luck.

Pulling (through HTTP) works fine.

I'm using hgwebdir to serve my repo.

What else should I check?

I found this: http://code.google.com/p/support/issues/detail?id=2580 In my case it's not random, it happens every single time.

Relevant part of my vhost conf:

  WSGIScriptAlias  /  /home/(...)/hgwebdir.wsgi

  <Directory /home/(...)>
    AuthType Basic
    AuthUserFile /(...)/basic-password
    AuthName (...)
    Require valid-user

    Order deny,allow
    Allow from all
  </Directory>

$ hg -v
Mercurial Distributed SCM (version 1.0.2)

Strangely enough hg outgoing works ok:

$ hg outgoing
comparing with https://hg.domain.com/X_repo
http authorization required
realm: ...
user: ...
password: 
searching for changes
changeset:   64:...
tag:         tip
user:        ...
date:        ...
summary:     ...
Piotr Byzia
  • 3,363
  • 7
  • 42
  • 62

8 Answers8

54

If anybody wants to make it run on local machine then adding this to server REPO/.hg/hgrc will do the work:

[web]
allow_push = *
push_ssl = false

as described at this site.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
lukmdo
  • 7,489
  • 5
  • 30
  • 23
21

Problem turned out to be repo dir permissions. chown www-data solved it...

Piotr Byzia
  • 3,363
  • 7
  • 42
  • 62
  • 15
    Don't forget that you also need allow_push in the [web] section of your .hg/hgrc – Frank Shearar Sep 09 '09 at 07:36
  • 6
    $ sudo chown -R wwwrun:www /srv/www/htdocs/hg/reposfrom https://www.mercurial-scm.org/wiki/HgWebDirStepByStep Section 7, for those not so good with linux. – bulltorious Dec 07 '10 at 14:32
  • 2
    For those using Ubuntu: sudo chown -R www-data:www-data /var/hg/repos – Houman Mar 04 '12 at 14:28
  • Even I put the owner ship to 'www-data' I still have the problem:password: sending [================================================================================>] 6/6 01sabort: authorization failed – Kemin Zhou Sep 10 '15 at 18:47
  • To check for the apache user on the system, have a look at /etc/passwd – logicbloke Mar 19 '18 at 05:17
3

For those with TortoiseHg pushing to a web server (another unauthorized user on another PC):

In TortoiseHg: File - Settings - (Either globally or just for the current repository - tabs) then the Server settings. Web Server

Push Requires SSL - No
Allow Push - *

This does the same thing through the UI as lukmdo's answer above (editing the hgrc file).

lko
  • 8,161
  • 9
  • 45
  • 62
  • No, lukmdo's answer is server-side. Changing this client-side doesn't help. I have repositories with the first setting undefined (default value), and I manage to push to them without HTTPS. – Philippe Cloutier Apr 14 '23 at 17:59
3

It is strange that you can run hg outgoing but not hg push since it is my understanding that they both authenticate in the same way.

Unfortunately I'm not a hgweb expert. Please mail to the Mercurial list (mercurial@mercurial-scm.org) and/or come online in IRC (#mercurial on irc.freenode.net). There will be many more people to help you there. IRC is especially good since these things are much easier to debug interactively.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
1

Just in case it might help someone - I encountered this error for unknown reasons, all permissions were OK, and just restarting apache solved it.

Kjetil Limkjær
  • 1,550
  • 12
  • 22
1

My problem was a bit different. Password change triggered it... And I had a repo/.hgrc and a repo/.hg/hgrc. Not sure why, but these were conflicting.

For the record, the cleanest way I've found is to keep a global configuration file (on Windows C:\Users\<user>\mercurial.ini or Linux /home/<user>/.hgrc) with all the configuration that applies to all repositories (profiles, plugins/extensions, repos, etc), and then per repo, just use something like:

[paths]  
default = https://path/to/remote/repo

# any other repo-specific config

Why I had another repo-specific mercurial config file, I don't know -- now everything is cleaned up and working nicely.

nicorellius
  • 3,715
  • 4
  • 48
  • 79
0

This happened to me after changing my bitbucket password, then although I used SourceTree to manage my password and I changed it globaly, one repo however had my old password hard-coded in REPO/.hg/hgrc changed the line and all works again

Moak
  • 12,596
  • 27
  • 111
  • 166
0

My solution! If your are on Windows OS, you need to edit folder properties. Read/write permission.

enter image description here

Very Important!! Dont forget turn off the web server, edit folder properties and turn on again the web server tortoiseHG

Red
  • 26,798
  • 7
  • 36
  • 58