Patchwork [V4] hgweb: don't attempt to show hidden bookmarks (issue3774)

login
register
mail settings
Submitter Kevin Bullock
Date Jan. 26, 2013, 6:31 p.m.
Message ID <0af7b5dc492f6573cec3.1359225076@Slower-Than-Infinity.local>
Download mbox | patch
Permalink /patch/742/
State Accepted
Commit 886936ecc21bed5e9bc1a244b22f4b203d3c3ace
Headers show

Comments

Kevin Bullock - Jan. 26, 2013, 6:31 p.m.
# HG changeset patch
# User Kevin Bullock <kbullock@ringworld.org>
# Date 1359135834 21600
# Branch stable
# Node ID 0af7b5dc492f6573cec334b2ba0c7cebc2320b9c
# Parent  010d6d3fcfee422f4dd458321c6f540954548d7e
hgweb: don't attempt to show hidden bookmarks (issue3774)

localrepository._bookmarks is unfiltered, but hgweb gets a filtered
repo. This fixes the resulting traceback on the 'bookmarks' page.
Idan Kamara - Jan. 26, 2013, 9:10 p.m.
On Sat, Jan 26, 2013 at 8:31 PM, Kevin Bullock <
kbullock+mercurial@ringworld.org> wrote:
>
> # HG changeset patch
> # User Kevin Bullock <kbullock@ringworld.org>
> # Date 1359135834 21600
> # Branch stable
> # Node ID 0af7b5dc492f6573cec334b2ba0c7cebc2320b9c
> # Parent  010d6d3fcfee422f4dd458321c6f540954548d7e
> hgweb: don't attempt to show hidden bookmarks (issue3774)
>
> localrepository._bookmarks is unfiltered, but hgweb gets a filtered
> repo. This fixes the resulting traceback on the 'bookmarks' page.

Isn't the problem a little bit deeper than removing the
filtered bookmarks here? Every other place that will look
at repo._bookmarks will have to do the same check.

Perhaps repoview.__init__ needs to call something that
will cause repo._bookmarks to reconstruct itself (along
with other objects that are based on possibly filtered
csets), which will make those bookmarks not show up in
the first place (repo.invalidatecaches seems like a good
candidate but that requires some extra work).

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -424,7 +424,7 @@  def tags(web, req, tmpl):
                 latestentry=lambda **x: entries(True, True, **x))
 
 def bookmarks(web, req, tmpl):
-    i = web.repo._bookmarks.items()
+    i = [b for b in web.repo._bookmarks.items() if b[1] in web.repo]
     parity = paritygen(web.stripecount)
 
     def entries(latestonly, **map):
diff --git a/tests/test-hgweb-commands.t b/tests/test-hgweb-commands.t
--- a/tests/test-hgweb-commands.t
+++ b/tests/test-hgweb-commands.t
@@ -1370,4 +1370,23 @@  Test paging
 
   $ cat errors.log
 
+issue3774
+
+  $ hg phase -fs 4
+  $ hg bookmark -r4 secret
+  $ cat >hgweb.cgi <<HGWEB
+  > import cgitb
+  > cgitb.enable()
+  > from mercurial import demandimport; demandimport.enable()
+  > from mercurial.hgweb import hgweb
+  > from mercurial.hgweb import wsgicgi
+  > app = hgweb('.', 'test')
+  > wsgicgi.launch(app)
+  > HGWEB
+  $ . "$TESTDIR/cgienv"
+  $ PATH_INFO=/bookmarks; export PATH_INFO
+  $ REQUEST_URI=/test/bookmarks; export REQUEST_URI
+  $ QUERY_STRING='style=raw'
+  $ python hgweb.cgi
+
   $ cd ..