[PATCH STABLE] mq: comply with filtering when injecting fake tags (issue3812)

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Mon Feb 11 09:25:48 CST 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1360596108 -3600
# Branch stable
# Node ID ed7241a612835bb22759d93df4c1522961cd6823
# Parent  227479f61db9d169c1afea6fa0a9dce7288d4932
mq: comply with filtering when injecting fake tags (issue3812)

mq was injecting fake tags whenever the revision were accessible to the
filtering level.

This issue impacts hgweb since it's common to have "secret" mq patches. As secret
changeset are filtered by hgweb the tags computation could break.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -3452,10 +3452,16 @@ def reposetup(ui, repo):
             except error.LookupError:
                 self.ui.warn(_('mq status file refers to unknown node %s\n')
                              % short(mqtags[-1][0]))
                 return result
 
+            # do not add fake tags for filtered revision
+            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'))
             tags = result[0]
             for patch in mqtags:
diff --git a/tests/test-mq.t b/tests/test-mq.t
--- a/tests/test-mq.t
+++ b/tests/test-mq.t
@@ -1553,6 +1553,26 @@ Test that qfinish preserve phase when mq
   $ hg phase 'all()'
   0: draft
   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 ..


More information about the Mercurial-devel mailing list