Mercurial > hg
changeset 1213:db9639b8594c
Clean up hgweb imports
Use demandloading
Pull function-local imports up to demandload
Scope hg and ui bits
author | mpm@selenic.com |
---|---|
date | Wed, 07 Sep 2005 23:13:12 -0700 |
parents | ccb6201e3f28 |
children | 34706a835d4a |
files | mercurial/hgweb.py |
diffstat | 1 files changed, 8 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb.py Wed Sep 07 20:50:23 2005 -0700 +++ b/mercurial/hgweb.py Wed Sep 07 23:13:12 2005 -0700 @@ -6,11 +6,11 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, cgi, time, re, socket, sys, zlib, errno -import mdiff -from hg import * -from ui import * - +import os, cgi, sys +from demandload import demandload +demandload(globals(), "mdiff time re socket zlib errno ui hg") +demandload(globals(), "zipfile tempfile StringIO tarfile BaseHTTPServer") +from node import * def templatepath(): for f in "templates", "../templates": @@ -171,7 +171,7 @@ class hgweb: def __init__(self, repo, name=None): if type(repo) == type(""): - self.repo = repository(ui(), repo) + self.repo = hg.repository(ui.ui(), repo) else: self.repo = repo @@ -183,7 +183,7 @@ s = os.stat(os.path.join(self.repo.root, ".hg", "00changelog.i")) if s.st_mtime != self.mtime: self.mtime = s.st_mtime - self.repo = repository(self.repo.ui, self.repo.root) + self.repo = hg.repository(self.repo.ui, self.repo.root) self.maxchanges = self.repo.ui.config("web", "maxchanges", 10) self.maxfiles = self.repo.ui.config("web", "maxchanges", 10) self.allowpull = self.repo.ui.configbool("web", "allowpull", True) @@ -660,8 +660,6 @@ files.sort() if type == 'zip': - import zipfile, tempfile - tmp = tempfile.mkstemp()[1] try: zf = zipfile.ZipFile(tmp, "w", zipfile.ZIP_DEFLATED) @@ -679,10 +677,6 @@ os.unlink(tmp) else: - import StringIO - import time - import tarfile - tf = tarfile.TarFile.open(mode='w|' + type, fileobj=req.out) mff = self.repo.manifest.readflags(mnode) mtime = int(time.time()) @@ -849,8 +843,6 @@ accesslog = openlog(repo.ui.config("web", "accesslog", "-"), sys.stdout) errorlog = openlog(repo.ui.config("web", "errorlog", "-"), sys.stderr) - import BaseHTTPServer - class IPv6HTTPServer(BaseHTTPServer.HTTPServer): address_family = getattr(socket, 'AF_INET6', None) @@ -962,7 +954,7 @@ def entries(**map): parity = 0 for name, path in self.repos: - u = ui() + u = ui.ui() try: u.readconfig(file(os.path.join(path, '.hg', 'hgrc'))) except IOError: