Patchwork [23,of,23,Series-D] hgweb: run with "unserved" filter

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 11, 2013, 12:24 a.m.
Message ID <90ab0b86f7ea316c5024.1357863848@yamac.lan>
Download mbox | patch
Permalink /patch/550/
State Superseded
Headers show

Comments

Pierre-Yves David - Jan. 11, 2013, 12:24 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1357863817 -3600
# Node ID 90ab0b86f7ea316c50248c4d5a1e306140adecc6
# Parent  e1cdae2adebfbf5dcbf401d70ebd69d129f63195
hgweb: run with "unserved" filter

This changeset enable the "unserved" filter on all repo used by hgweb.

Hgweb misbehave in a lot of when filtering changeset are present but I do not
expect normal people to have secret of obsolete changeset on they server.
Misbehavior will be gradually fixed later.
Mads Kiilerich - Jan. 12, 2013, 1:58 p.m.
Pierre-Yves David wrote, On 01/11/2013 01:24 AM:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@logilab.fr>
> # Date 1357863817 -3600
> # Node ID 90ab0b86f7ea316c50248c4d5a1e306140adecc6
> # Parent  e1cdae2adebfbf5dcbf401d70ebd69d129f63195
> hgweb: run with "unserved" filter
>
> This changeset enable the "unserved" filter on all repo used by hgweb.
>
> Hgweb misbehave in a lot of when filtering changeset are present but I do not
> expect normal people to have secret of obsolete changeset on they server.
> Misbehavior will be gradually fixed later.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -5276,10 +5276,15 @@ def serve(ui, repo, **opts):
>       def checkrepo():
>           if repo is None:
>               raise error.RepoError(_("there is no Mercurial repository here"
>                                 " (.hg not found)"))
>   
> +

(No bonus points for extra blank lines.)

> +    if not opts["cmdserver"]:
> +        if repo is not None:
> +            repo = repo.filtered('unserved')
> +

hgweb will create its own repo instances anyway and presumably get the 
setting there, so I assume this sshserver only and should be moved to 
the stdio case below?

>       if opts["stdio"]:
>           checkrepo()
>           s = sshserver.sshserver(ui, repo)
>           s.serve_forever()
>   
> diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
> --- a/mercurial/hgweb/hgweb_mod.py
> +++ b/mercurial/hgweb/hgweb_mod.py
> @@ -57,10 +57,11 @@ class hgweb(object):
>                   u = ui.ui()
>               self.repo = hg.repository(u, repo)
>           else:
>               self.repo = repo
>   
> +        self.repo =  self.repo.filtered('unserved')

+1 to keeping self.repo as the repo that actually is used and to avoid 
assigning temporary values of other "types" to it. That would also 
remove a couple of lines.

>           self.repo.ui.setconfig('ui', 'report_untrusted', 'off')
>           self.repo.ui.setconfig('ui', 'nontty', 'true')
>           hook.redirect(True)
>           self.mtime = -1
>           self.size = -1
> @@ -93,10 +94,11 @@ class hgweb(object):
>           # rollbacks made less than a second ago
>           if st.st_mtime != self.mtime or st.st_size != self.size:
>               self.mtime = st.st_mtime
>               self.size = st.st_size
>               self.repo = hg.repository(self.repo.ui, self.repo.root)
> +            self.repo =  self.repo.filtered('unserved')

check-code should have said hi to extra spaces ...

/Mads

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5276,10 +5276,15 @@  def serve(ui, repo, **opts):
     def checkrepo():
         if repo is None:
             raise error.RepoError(_("there is no Mercurial repository here"
                               " (.hg not found)"))
 
+
+    if not opts["cmdserver"]:
+        if repo is not None:
+            repo = repo.filtered('unserved')
+
     if opts["stdio"]:
         checkrepo()
         s = sshserver.sshserver(ui, repo)
         s.serve_forever()
 
diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -57,10 +57,11 @@  class hgweb(object):
                 u = ui.ui()
             self.repo = hg.repository(u, repo)
         else:
             self.repo = repo
 
+        self.repo =  self.repo.filtered('unserved')
         self.repo.ui.setconfig('ui', 'report_untrusted', 'off')
         self.repo.ui.setconfig('ui', 'nontty', 'true')
         hook.redirect(True)
         self.mtime = -1
         self.size = -1
@@ -93,10 +94,11 @@  class hgweb(object):
         # rollbacks made less than a second ago
         if st.st_mtime != self.mtime or st.st_size != self.size:
             self.mtime = st.st_mtime
             self.size = st.st_size
             self.repo = hg.repository(self.repo.ui, self.repo.root)
+            self.repo =  self.repo.filtered('unserved')
             self.maxchanges = int(self.config("web", "maxchanges", 10))
             self.stripecount = int(self.config("web", "stripes", 1))
             self.maxshortchanges = int(self.config("web", "maxshortchanges",
                                                    60))
             self.maxfiles = int(self.config("web", "maxfiles", 10))