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

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 11, 2013, 3:25 p.m.
Message ID <ed7241a612835bb22759.1360596348@crater2.logilab.fr>
Download mbox | patch
Permalink /patch/962/
State Accepted
Commit c5f7e83d47cd8e6eccc213ef507c0d5db9fc329e
Headers show

Comments

Pierre-Yves David - Feb. 11, 2013, 3:25 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.
Bryan O'Sullivan - Feb. 11, 2013, 9:12 p.m.
On Mon, Feb 11, 2013 at 7:25 AM, <pierre-yves.david@logilab.fr> wrote:

> mq: comply with filtering when injecting fake tags (issue3812)
>

Crewed, thanks.

Patch

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 ..