Patchwork [3,of,4,main-line-of-work] hg-ssh: reject push earlier (on pretxnopen)

mail settings
Submitter Pierre-Yves David
Date May 16, 2015, 1:45 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/9113/
State Accepted
Headers show


Pierre-Yves David - May 16, 2015, 1:45 a.m.
# HG changeset patch
# User Pierre-Yves David <>
# Date 1431257951 25200
#      Sun May 10 04:39:11 2015 -0700
# Node ID c66322e088ae697101200a961480c5f8ff171997
# Parent  55241a70eec911a50eb70cff82139885dcedad6d
hg-ssh: reject push earlier (on pretxnopen)

We now have a lock triggered for any transaction. We use it to ensure no-read
are made in read-only mode. We need more that just "no changegroup is added",
since bundle2 allows for more than just changegroup to be exchanged.  We still
protect pushkey as it may write data without opening a transaction.


diff --git a/contrib/hg-ssh b/contrib/hg-ssh
--- a/contrib/hg-ssh
+++ b/contrib/hg-ssh
@@ -62,11 +62,11 @@  def main():
         if repo in allowed_paths:
             cmd = ['-R', repo, 'serve', '--stdio']
             if readonly:
                 cmd += [
-                    'hooks.prechangegroup.hg-ssh=python:__main__.rejectpush',
+                    'hooks.pretxnopen.hg-ssh=python:__main__.rejectpush',
diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -396,11 +396,11 @@  Test hg-ssh in read-only mode:
   $ hg ci -A -m "unpushable commit" bar
   $ hg push --ssh "sh ../"
   pushing to ssh://user@dummy/*/remote (glob)
   searching for changes
   remote: Permission denied
-  remote: abort: prechangegroup.hg-ssh hook failed
+  remote: abort: pretxnopen.hg-ssh hook failed
   remote: Permission denied
   remote: pushkey-abort: prepushkey.hg-ssh hook failed
   updating 6c0482d977a3 to public failed!