Patchwork D1142: dispatch: filter the repository depending on func.cmdtype

login
register
mail settings
Submitter phabricator
Date Oct. 17, 2017, 12:19 p.m.
Message ID <differential-rev-PHID-DREV-56epicgn6pjruwjt3i6f-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/25090/
State Superseded
Headers show

Comments

phabricator - Oct. 17, 2017, 12:19 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch adds support for filtering the repository on the basis of
  func.cmdtype. After this patch, repo.filtername will be used to decide what
  level of access the running command can has on hidden commits.
  
  All this logic is behind a config flag `experimental.directacess` which defaults
  to False.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1142

AFFECTED FILES
  mercurial/configitems.py
  mercurial/dispatch.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Oct. 18, 2017, 4:17 p.m.
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  Seems reasonable as an experimental feature.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1142

To: pulkit, #hg-reviewers, indygreg
Cc: indygreg, dlax, mercurial-devel

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -42,6 +42,8 @@ 
 )
 
 unrecoverablewrite = registrar.command.unrecoverablewrite
+recoverablewrite = registrar.command.recoverablewrite
+readonly = registrar.command.readonly
 
 class request(object):
     def __init__(self, args, ui=None, repo=None, fin=None, fout=None,
@@ -927,6 +929,14 @@ 
                 ui = repo.ui
                 if options['hidden']:
                     repo = repo.unfiltered()
+
+                # Accessing hidden commits based on func.cmdtype
+                if lui.configbool('experimental', 'directaccess'):
+                    if func.cmdtype == readonly:
+                        repo = repo.filtered('visible-hidden')
+                    elif func.cmdtype == recoverablewrite:
+                        repo = repo.filtered('visible-warnhidden')
+
             args.insert(0, repo)
         elif rpath:
             ui.warn(_("warning: --repository ignored\n"))
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -334,6 +334,9 @@ 
 coreconfigitem('experimental', 'crecordtest',
     default=None,
 )
+coreconfigitem('experimental', 'directaccess',
+    default=False,
+)
 coreconfigitem('experimental', 'editortmpinhg',
     default=False,
 )