Patchwork [2,of,2,STABLE] hgweb: fix a crash when web.archivesubrepos

login
register
mail settings
Submitter Matt Harbison
Date Nov. 6, 2014, 3:01 a.m.
Message ID <5b085d95a61c5b4a0d44.1415242908@Envy>
Download mbox | patch
Permalink /patch/6596/
State Accepted
Headers show

Comments

Matt Harbison - Nov. 6, 2014, 3:01 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1415241225 18000
#      Wed Nov 05 21:33:45 2014 -0500
# Branch stable
# Node ID 5b085d95a61c5b4a0d445758393c5fe1f4ce9d56
# Parent  f59cc3beff0775b13d9d2f00192b9f7bfff9956e
hgweb: fix a crash when web.archivesubrepos

A matcher is required when enabling the subrepo option on archival.archive(),
because that calls match.narrowmatcher(), which accesses fields on the object.
It's therefore probably a bad idea to default the matcher to None on archive(),
but that's a fix for default.
Pierre-Yves David - Nov. 7, 2014, 5:55 p.m.
On 11/06/2014 03:01 AM, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1415241225 18000
> #      Wed Nov 05 21:33:45 2014 -0500
> # Branch stable
> # Node ID 5b085d95a61c5b4a0d445758393c5fe1f4ce9d56
> # Parent  f59cc3beff0775b13d9d2f00192b9f7bfff9956e
> hgweb: fix a crash when web.archivesubrepos

This series looks okay. It is pushed to the clowncopter.

Patch

# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1415241225 18000
#      Wed Nov 05 21:33:45 2014 -0500
# Branch stable
# Node ID 5b085d95a61c5b4a0d445758393c5fe1f4ce9d56
# Parent  f59cc3beff0775b13d9d2f00192b9f7bfff9956e
hgweb: fix a crash when web.archivesubrepos

A matcher is required when enabling the subrepo option on archival.archive(),
because that calls match.narrowmatcher(), which accesses fields on the object.
It's therefore probably a bad idea to default the matcher to None on archive(),
but that's a fix for default.

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -901,7 +901,7 @@ 
 
     ctx = webutil.changectx(web.repo, req)
     pats = []
-    matchfn = None
+    matchfn = scmutil.match(ctx, [])
     file = req.form.get('file', None)
     if file:
         pats = ['path:' + file[0]]
diff --git a/tests/test-archive.t b/tests/test-archive.t
--- a/tests/test-archive.t
+++ b/tests/test-archive.t
@@ -20,6 +20,7 @@ 
   $ hg ci -m "add subrepo"
   $ echo "[web]" >> .hg/hgrc
   $ echo "name = test-archive" >> .hg/hgrc
+  $ echo "archivesubrepos = True" >> .hg/hgrc
   $ cp .hg/hgrc .hg/hgrc-base
   > test_archtype() {
   >     echo "allow_archive = $1" >> .hg/hgrc
@@ -95,6 +96,7 @@ 
   test-archive-1701ef1f1510/bar
   test-archive-1701ef1f1510/baz/bletch
   test-archive-1701ef1f1510/foo
+  test-archive-1701ef1f1510/subrepo/sub
   $ python getarchive.py "$TIP" bz2 | bunzip2 | tar tf - 2>/dev/null
   test-archive-1701ef1f1510/.hg_archival.txt
   test-archive-1701ef1f1510/.hgsub
@@ -102,6 +104,7 @@ 
   test-archive-1701ef1f1510/bar
   test-archive-1701ef1f1510/baz/bletch
   test-archive-1701ef1f1510/foo
+  test-archive-1701ef1f1510/subrepo/sub
   $ python getarchive.py "$TIP" zip > archive.zip
   $ unzip -t archive.zip
   Archive:  archive.zip
@@ -111,6 +114,7 @@ 
       testing: test-archive-1701ef1f1510/bar   OK
       testing: test-archive-1701ef1f1510/baz/bletch   OK
       testing: test-archive-1701ef1f1510/foo   OK
+      testing: test-archive-1701ef1f1510/subrepo/sub   OK
   No errors detected in compressed data of archive.zip.
 
 test that we can download single directories and files