Patchwork [STABLE] largefiles: make sure debugstate command is populated before wrapping

login
register
mail settings
Submitter Yuya Nishihara
Date May 4, 2017, 7:12 a.m.
Message ID <037baeadd16765992775.1493881948@mimosa>
Download mbox | patch
Permalink /patch/20428/
State Accepted
Headers show

Comments

Yuya Nishihara - May 4, 2017, 7:12 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1493879031 -32400
#      Thu May 04 15:23:51 2017 +0900
# Branch stable
# Node ID 037baeadd16765992775e027e8cf5fd4cca1f28b
# Parent  40785ccab41006f61039714d0d9b2ed09e401b2a
largefiles: make sure debugstate command is populated before wrapping

Copied the hack from 869d660b8669, which seemed the simplest workaround.
Perhaps debugcommands.py should have its own commands table.
Augie Fackler - May 6, 2017, 4:53 p.m.
On Thu, May 04, 2017 at 04:12:28PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1493879031 -32400
> #      Thu May 04 15:23:51 2017 +0900
> # Branch stable
> # Node ID 037baeadd16765992775e027e8cf5fd4cca1f28b
> # Parent  40785ccab41006f61039714d0d9b2ed09e401b2a
> largefiles: make sure debugstate command is populated before wrapping

queued, thanks

Patch

diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -21,6 +21,7 @@  from mercurial import (
     cmdutil,
     commands,
     copies,
+    debugcommands,
     exchange,
     extensions,
     filemerge,
@@ -39,6 +40,11 @@  from . import (
 )
 
 def uisetup(ui):
+    # TODO: debugcommands should use a separate command table
+    # Side-effect of accessing is debugcommands module is guaranteed to be
+    # imported and commands.table is populated.
+    debugcommands.command
+
     # Disable auto-status for some commands which assume that all
     # files in the result are under Mercurial's control
 
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -212,6 +212,25 @@  Test display of largefiles in hgweb
   $ killdaemons.py
 #endif
 
+Test largefiles can be loaded in hgweb (wrapcommand() shouldn't fail)
+
+  $ cat <<EOF > "$TESTTMP/hgweb.cgi"
+  > #!/usr/bin/env python
+  > from mercurial import demandimport; demandimport.enable()
+  > from mercurial.hgweb import hgweb
+  > from mercurial.hgweb import wsgicgi
+  > application = hgweb('.', 'test repo')
+  > wsgicgi.launch(application)
+  > EOF
+
+  $ PATH_INFO='/' \
+  > QUERY_STRING='' \
+  > REQUEST_METHOD='GET' \
+  > SCRIPT_NAME='' \
+  > SERVER_NAME='localhost' \
+  > SERVER_PORT='80' \
+  > python "$TESTTMP/hgweb.cgi" > /dev/null
+
 Test archiving the various revisions.  These hit corner cases known with
 archiving.