changeset 18662:c5f7e83d47cd

mq: comply with filtering when injecting fake tags (issue3812) mq was injecting fake tags whenever the revisions were accessible to the filtering level. This issue impacts hgweb since it's common to have "secret" mq patches. As secret changesets are filtered by hgweb, the tags computation could break.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 11 Feb 2013 16:21:48 +0100
parents 4fb92f14a97a
children 05cf40f9b0ec
files hgext/mq.py tests/test-mq.t
diffstat 2 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Fri Feb 08 05:36:08 2013 -0800
+++ b/hgext/mq.py	Mon Feb 11 16:21:48 2013 +0100
@@ -3454,6 +3454,12 @@
                              % short(mqtags[-1][0]))
                 return result
 
+            # do not add fake tags for filtered revisions
+            included = self.changelog.hasnode
+            mqtags = [mqt for mqt in mqtags if included(mqt[0])]
+            if not mqtags:
+                return result
+
             mqtags.append((mqtags[-1][0], 'qtip'))
             mqtags.append((mqtags[0][0], 'qbase'))
             mqtags.append((self.changelog.parents(mqtags[0][0])[0], 'qparent'))
--- a/tests/test-mq.t	Fri Feb 08 05:36:08 2013 -0800
+++ b/tests/test-mq.t	Mon Feb 11 16:21:48 2013 +0100
@@ -1555,4 +1555,24 @@
   1: secret
   2: secret
 
+Test that secret mq patch does not break hgweb
+
+  $ cat > hgweb.cgi <<HGWEB
+  > from mercurial import demandimport; demandimport.enable()
+  > from mercurial.hgweb import hgweb
+  > from mercurial.hgweb import wsgicgi
+  > import cgitb
+  > cgitb.enable()
+  > app = hgweb('.', 'test')
+  > wsgicgi.launch(app)
+  > HGWEB
+  $ . "$TESTDIR/cgienv"
+  $ PATH_INFO=/tags; export PATH_INFO
+  $ QUERY_STRING='style=raw'
+  $ python hgweb.cgi | grep -v ETag:
+  Status: 200 Script output follows\r (esc)
+  Content-Type: text/plain; charset=ascii\r (esc)
+  \r (esc)
+  tip	[0-9a-f]{40} (re)
+
   $ cd ..