Patchwork clfilter: enforce hidden filtering on all repository

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 11, 2013, 7:35 p.m.
Message ID <6ec049950ff68fd596da.1357932925@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/560/
State Accepted
Headers show

Comments

Pierre-Yves David - Jan. 11, 2013, 7:35 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1357932894 -3600
# Node ID 6ec049950ff68fd596daaba2fca50ac5cd4942eb
# Parent  65cec7fa5472ed4c91f246dccd6e05ac49af02ab
clfilter: enforce hidden filtering on all repository

We ensure all repositores created through `mercurial.hg.repository` are "hidden"
filtered. This is an ever stronger enforcement than 5bb610f87d1d.

Citing Matt Mackall reply on changeset 5bb610f87d1d installing filtering in
dispatch:

> Unfortunately, this means that code that doesn't go through dispatch (ie all
> those crazy misguided people using Mercurial as a library) are going to see
> these hidden changesets.
>
> Might be better to instead install the filter in localrepo construction by
> default and disable it in dispatch.
Bryan O'Sullivan - Jan. 12, 2013, 4:17 a.m.
On Fri, Jan 11, 2013 at 08:35:25PM +0100, pierre-yves.david@logilab.fr wrote:
> clfilter: enforce hidden filtering on all repository

In crew, thanks.
Pierre-Yves David - Jan. 15, 2013, 9:39 a.m.
On Fri, Jan 11, 2013 at 08:17:43PM -0800, Bryan O'Sullivan wrote:
> On Fri, Jan 11, 2013 at 08:35:25PM +0100, pierre-yves.david@logilab.fr wrote:
> > clfilter: enforce hidden filtering on all repository
> 
> In crew, thanks.

This breaks hgweb with filtered changeset. See my Series-D thread for a fix.

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -708,13 +708,11 @@  def _dispatch(req):
         else:
             try:
                 repo = hg.repository(ui, path=path)
                 if not repo.local():
                     raise util.Abort(_("repository '%s' is not local") % path)
-                if not options['hidden']:
-                    repo = repo.filtered('hidden')
-                else:
+                if options['hidden']:
                     repo = repo.unfiltered()
                 repo.ui.setconfig("bundle", "mainreporoot", repo.root)
             except error.RequirementError:
                 raise
             except error.RepoError:
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -111,11 +111,11 @@  def repository(ui, path='', create=False
     peer = _peerorrepo(ui, path, create)
     repo = peer.local()
     if not repo:
         raise util.Abort(_("repository '%s' is not local") %
                          (path or peer.url()))
-    return repo
+    return repo.filtered('hidden')
 
 def peer(uiorrepo, opts, path, create=False):
     '''return a repository peer for the specified path'''
     rui = remoteui(uiorrepo, opts)
     return _peerorrepo(rui, path, create).peer()