author Gregory Szorc <gps@mozilla.com>
Tue, 28 Oct 2014 11:43:34 -0700
changeset 360276 7db4622ae530570abaf69b6ce2ffc6b08bdaa3d8
parent 360254 f0b48c38689d655918eed57955b681d05258669b
permissions -rw-r--r--
testing: add vcttesting to virtualenv The support modules in the vcttesting package are becoming increasingly popular. This directory currently must be manually added to sys.path. This is annoying. This patch adds packaging to vcttesting so it is available in our virtualenv. Scripts manually adding the testing directory to sys.path have been updated to no longer do this.

# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

"""Dummy extension to force hgwebdir to always refresh.

By default, hgwebdir only refreshes every 20 seconds. This means that if
we create a new repository, it doesn't appear on hgweb for 20 seconds.

We have tests that use hgwebdir and we need hgweb to respond to new
repositories without waiting 20 seconds or requiring a process restart.

Installing this extension forces hgwebdir to refresh on every request.
This does result in a slight performance loss. But this extension should
only be used as part of tests, so it shouldn't matter.

from mercurial.extensions import wrapfunction
import mercurial.hgweb as hgweb

def wrappedhgweb(orig, *args, **kwargs):
    web = orig(*args, **kwargs)

    if isinstance(web, hgweb.hgwebdir_mod.hgwebdir):
        web.refreshinterval = -1

    return web

def extsetup(ui):
    wrapfunction(hgweb, 'hgweb', wrappedhgweb)