Question

mercurial-server runs on Ubuntu 12.04 LTS

myserver@ip:/etc$ hg --version
    Mercurial Distributed SCM (version 2.0.2)
myserver@ip:/etc$ dpkg -s mercurial-server
    Package: mercurial-server
    Version: 1.2-1 
    ....

myserver@ip:/etc/mercurial-server/remote-hgrc.d$ ls -ltr
    total 12
    -rw-r--r-- 1 root root 180 Oct 10  2011 logging.rc
    -rw-r--r-- 1 root root 139 Oct 10  2011 access.rc
    -rw-r--r-- 1 root root  74 Mar 13 22:14 check.rc
myserver@ip:/etc/mercurial-server/remote-hgrc.d$ cat check.rc
    [hooks]
    pretxncommit.author_check = /SOURCE/mercurial-server/validate.sh

#manually added here too    
myserver@ip:/etc/mercurial-server/remote-hgrc.d$ cat ~hg/repos/hgadmin/.hg/hgrc
    # WARNING: when these hooks run they will entirely destroy and rewrite
    # ~/.ssh/authorized_keys

    [extensions]
    hgext.purge =

    [hooks]
    changegroup.aaaab_update = hg update -C default > /dev/null
    changegroup.aaaac_purge = hg purge --all > /dev/null
    changegroup.refreshauth = python:mercurialserver.refreshauth.hook
    pretxncommit.author_check = /SOURCE/mercurial-server/validate.sh

myserver@ip:/etc/mercurial-server/remote-hgrc.d$ cat /SOURCE/mercurial-server/validate.sh
    #!/bin/bash
    echo "REMUSR:$REMOTE_USER"
    echo "ATHR:`hg tip --template "{author}\n"`b"
    exit 1  

myserver@ip:~$ sudo -u hg cat ~hg/.ssh/authorized_keys
    no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command="/usr/share/mercurial-server/hg-ssh root/user1/user1.pub" ssh-rsa AAAAB3xOMN8ZiF user1@server.com
    no-pty,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,command="/usr/share/mercurial-server/hg-ssh users/user2/user2.pub" ssh-rsa AAAAB3N..0HchQQw== user2@server.com

After this from a local machine(Windows) I cloned a testproject ,changed,commited,push and it was successfull without any error or message.I tried this with both the initial user/key and a user/key added via hgadmin push

 D:\hg\testproj>hg push
   pushing to ssh://hg@myserver.com/testproj
   searching for changes
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
Was it helpful?

Solution

Works with

$ cat check.rc 
[hooks]
pretxnchangegroup.author_check = /SOURCE/mercurial-server/validate.sh

Not working with pretxncommit

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top