[PATCH] clfilter: enforce hidden filtering on all repository

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Fri Jan 11 13:35:25 CST 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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()


More information about the Mercurial-devel mailing list