[PATCH 2 of 2 evolve-ext] directaccess: disable directaccess for push and serve

Laurent Charignon lcharignon at fb.com
Tue Jun 16 13:21:19 CDT 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1434475157 25200
#      Tue Jun 16 10:19:17 2015 -0700
# Node ID 011113e915ff7766194a81075408a8d647a24051
# Parent  885f4825c3aceefc25cde5edb8c30c0e86201550
directaccess: disable directaccess for push and serve

Before this patch, push and serve were subject to directaccess. This patch
makes them throw error when trying to access hidden hashes.

diff --git a/hgext/directaccess.py b/hgext/directaccess.py
--- a/hgext/directaccess.py
+++ b/hgext/directaccess.py
@@ -22,6 +22,8 @@ command = cmdutil.command(cmdtable)
 directaccesslevel = [
     # 'warning' or 'error', (None if core) or extension name, command name
     ('warning', 'rebase', 'rebase'),
+    ('error', None, 'push'),
+    ('error', None, 'serve'),
 ]
 
 def reposetup(ui, repo):
diff --git a/tests/test-inhibit.t b/tests/test-inhibit.t
--- a/tests/test-inhibit.t
+++ b/tests/test-inhibit.t
@@ -721,5 +721,37 @@ Inhibit should not work without directac
   $ hg up 15
   abort: Cannot use inhibit without the direct access extension
   [255]
+  $ echo "directaccess=$(echo $(dirname $TESTDIR))/hgext/directaccess.py" >> $HGRCPATH
+  $ cd ..
 
 
+hg push should not allow directaccess unless forced with --hidden
+We copy the inhibhit repo to inhibit2 and make some changes to push to inhibit
+
+  $ cp -r inhibit inhibit2
+  $ pwd=$(pwd)
+  $ cd inhibit
+  $ mkcommit pk
+  $ hg id
+  003a4735afde tip
+  $ echo "OO" > pk
+  $ hg amend
+  $ hg id
+  71eb4f100663 tip
+
+Hidden commits cannot be pushed without --hidden
+  $ hg push -r 003a4735afde file://$pwd/inhibit2
+  pushing to file://$TESTTMP/inhibit2
+  abort: hidden revision '003a4735afde'!
+  (use --hidden to access hidden revisions)
+  [255]
+
+Visible commits can still be pushed
+  $ hg push -r 71eb4f100663 file://$pwd/inhibit2
+  pushing to file://$TESTTMP/inhibit2
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  2 new obsolescence markers


More information about the Mercurial-devel mailing list