changeset 6795:c228ae4bc89c

merge the backout head
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Wed, 02 Jul 2008 11:31:19 +0200
parents c64f35a96448 (diff) 8ff321a381d0 (current diff)
children 8909070fd05e
files mercurial/hgweb/protocol.py
diffstat 20 files changed, 182 insertions(+), 206 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/win32/mercurial.iss	Wed Jul 02 10:58:27 2008 +0200
+++ b/contrib/win32/mercurial.iss	Wed Jul 02 11:31:19 2008 +0200
@@ -2,7 +2,7 @@
 ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
 
 [Setup]
-AppCopyright=Copyright 2005-2007 Matt Mackall and others
+AppCopyright=Copyright 2005-2008 Matt Mackall and others
 AppName=Mercurial
 AppVerName=Mercurial snapshot
 InfoAfterFile=contrib/win32/postinstall.txt
@@ -18,7 +18,7 @@
 DefaultDirName={pf}\Mercurial
 SourceDir=..\..
 VersionInfoDescription=Mercurial distributed SCM
-VersionInfoCopyright=Copyright 2005-2007 Matt Mackall and others
+VersionInfoCopyright=Copyright 2005-2008 Matt Mackall and others
 VersionInfoCompany=Matt Mackall and others
 InternalCompressLevel=max
 SolidCompression=true
--- a/hgext/acl.py	Wed Jul 02 10:58:27 2008 +0200
+++ b/hgext/acl.py	Wed Jul 02 11:31:19 2008 +0200
@@ -46,77 +46,45 @@
 #   ** = user6
 
 from mercurial.i18n import _
-from mercurial.node import bin, short
 from mercurial import util
 import getpass
 
-class checker(object):
-    '''acl checker.'''
-
-    def buildmatch(self, key):
-        '''return tuple of (match function, list enabled).'''
-        if not self.ui.has_section(key):
-            self.ui.debug(_('acl: %s not enabled\n') % key)
-            return None, False
-
-        thisuser = self.getuser()
-        pats = [pat for pat, users in self.ui.configitems(key)
-                if thisuser in users.replace(',', ' ').split()]
-        self.ui.debug(_('acl: %s enabled, %d entries for user %s\n') %
-                      (key, len(pats), thisuser))
-        if pats:
-            match = util.matcher(self.repo.root, names=pats)[1]
-        else:
-            match = util.never
-        return match, True
-
-    def getuser(self):
-        '''return name of authenticated user.'''
-        return self.user
+def buildmatch(ui, repo, user, key):
+    '''return tuple of (match function, list enabled).'''
+    if not ui.has_section(key):
+        ui.debug(_('acl: %s not enabled\n') % key)
+        return None
 
-    def __init__(self, ui, repo):
-        self.ui = ui
-        self.repo = repo
-        self.user = getpass.getuser()
-        cfg = self.ui.config('acl', 'config')
-        if cfg:
-            self.ui.readsections(cfg, 'acl.allow', 'acl.deny')
-        self.allow, self.allowable = self.buildmatch('acl.allow')
-        self.deny, self.deniable = self.buildmatch('acl.deny')
-
-    def skipsource(self, source):
-        '''true if incoming changes from this source should be skipped.'''
-        ok_sources = self.ui.config('acl', 'sources', 'serve').split()
-        return source not in ok_sources
-
-    def check(self, node):
-        '''return if access allowed, raise exception if not.'''
-        files = self.repo[node].files()
-        if self.deniable:
-            for f in files:
-                if self.deny(f):
-                    self.ui.debug(_('acl: user %s denied on %s\n') %
-                                  (self.getuser(), f))
-                    raise util.Abort(_('acl: access denied for changeset %s') %
-                                     short(node))
-        if self.allowable:
-            for f in files:
-                if not self.allow(f):
-                    self.ui.debug(_('acl: user %s not allowed on %s\n') %
-                                  (self.getuser(), f))
-                    raise util.Abort(_('acl: access denied for changeset %s') %
-                                     short(node))
-        self.ui.debug(_('acl: allowing changeset %s\n') % short(node))
+    pats = [pat for pat, users in ui.configitems(key)
+            if user in users.replace(',', ' ').split()]
+    ui.debug(_('acl: %s enabled, %d entries for user %s\n') %
+             (key, len(pats), user))
+    if pats:
+        return util.matcher(repo.root, names=pats)[1]
+    return util.never
 
 def hook(ui, repo, hooktype, node=None, source=None, **kwargs):
     if hooktype != 'pretxnchangegroup':
         raise util.Abort(_('config error - hook type "%s" cannot stop '
                            'incoming changesets') % hooktype)
-
-    c = checker(ui, repo)
-    if c.skipsource(source):
+    if source not in ui.config('acl', 'sources', 'serve').split():
         ui.debug(_('acl: changes have source "%s" - skipping\n') % source)
         return
 
-    for rev in xrange(repo[node].rev(), len(repo)):
-        c.check(repo.changelog.node(rev))
+    user = getpass.getuser()
+    cfg = ui.config('acl', 'config')
+    if cfg:
+        ui.readsections(cfg, 'acl.allow', 'acl.deny')
+    allow = buildmatch(ui, repo, user, 'acl.allow')
+    deny = buildmatch(ui, repo, user, 'acl.deny')
+
+    for rev in xrange(repo[node], len(repo)):
+        ctx = repo[rev]
+        for f in ctx.files():
+            if deny and deny(f):
+                ui.debug(_('acl: user %s denied on %s\n') % (user, f))
+                raise util.Abort(_('acl: access denied for changeset %s') % ctx)
+            if allow and not allow(f):
+                ui.debug(_('acl: user %s not allowed on %s\n') % (user, f))
+                raise util.Abort(_('acl: access denied for changeset %s') % ctx)
+        ui.debug(_('acl: allowing changeset %s\n') % ctx)
--- a/mercurial/commands.py	Wed Jul 02 10:58:27 2008 +0200
+++ b/mercurial/commands.py	Wed Jul 02 11:31:19 2008 +0200
@@ -110,8 +110,8 @@
     ctx = repo[opts['rev']]
 
     m = cmdutil.match(repo, pats, opts)
-    for abs in repo.walk(m, ctx.node()):
-        fctx = ctx.filectx(abs)
+    for abs in ctx.walk(m):
+        fctx = ctx[abs]
         if not opts['text'] and util.binary(fctx.data()):
             ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
             continue
@@ -485,9 +485,9 @@
     ctx = repo[opts['rev']]
     err = 1
     m = cmdutil.match(repo, (file1,) + pats, opts)
-    for abs in repo.walk(m, ctx.node()):
+    for abs in ctx.walk(m):
         fp = cmdutil.make_file(repo, opts['output'], ctx.node(), pathname=abs)
-        data = ctx.filectx(abs).data()
+        data = ctx[abs].data()
         if opts.get('decode'):
             data = repo.wwritedata(abs, data)
         fp.write(data)
@@ -907,8 +907,8 @@
 
     ctx = repo[opts.get('rev')]
     m = cmdutil.match(repo, (file1,) + pats, opts)
-    for abs in repo.walk(m, ctx.node()):
-        fctx = ctx.filectx(abs)
+    for abs in ctx.walk(m):
+        fctx = ctx[abs]
         o = fctx.filelog().renamed(fctx.filenode())
         rel = m.rel(abs)
         if o:
@@ -1693,17 +1693,13 @@
     that contain white space as multiple filenames.
     """
     end = opts['print0'] and '\0' or '\n'
-    rev = opts['rev']
-    if rev:
-        node = repo.lookup(rev)
-    else:
-        node = None
+    rev = opts.get('rev') or None
 
     ret = 1
     m = cmdutil.match(repo, pats, opts, default='relglob')
     m.bad = lambda x,y: False
-    for abs in repo.walk(m, node):
-        if not node and abs not in repo.dirstate:
+    for abs in repo[rev].walk(m):
+        if not rev and abs not in repo.dirstate:
             continue
         if opts['fullpath']:
             ui.write(os.path.join(repo.root, abs), end)
@@ -2350,7 +2346,7 @@
 
         m = cmdutil.match(repo, pats, opts)
         m.bad = badfn
-        for abs in repo.walk(m, node=node):
+        for abs in repo[node].walk(m):
             if abs not in names:
                 names[abs] = m.rel(abs), m.exact(abs)
 
--- a/mercurial/context.py	Wed Jul 02 10:58:27 2008 +0200
+++ b/mercurial/context.py	Wed Jul 02 11:31:19 2008 +0200
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms
 # of the GNU General Public License, incorporated herein by reference.
 
-from node import nullid, nullrev, short
+from node import nullid, nullrev, short, hex
 from i18n import _
 import ancestor, bdiff, revlog, util, os, errno
 
@@ -23,6 +23,9 @@
     def __str__(self):
         return short(self.node())
 
+    def __int__(self):
+        return self.rev()
+
     def __repr__(self):
         return "<changectx %s>" % str(self)
 
@@ -79,6 +82,7 @@
 
     def rev(self): return self._rev
     def node(self): return self._node
+    def hex(self): return hex(self._node)
     def user(self): return self._changeset[1]
     def date(self): return self._changeset[2]
     def files(self): return self._changeset[3]
@@ -142,6 +146,23 @@
         n = self._repo.changelog.ancestor(self._node, c2._node)
         return changectx(self._repo, n)
 
+    def walk(self, match):
+        fdict = dict.fromkeys(match.files())
+        # for dirstate.walk, files=['.'] means "walk the whole tree".
+        # follow that here, too
+        fdict.pop('.', None)
+        for fn in self:
+            for ffn in fdict:
+                # match if the file is the exact name or a directory
+                if ffn == fn or fn.startswith("%s/" % ffn):
+                    del fdict[ffn]
+                    break
+            if match(fn):
+                yield fn
+        for fn in util.sort(fdict):
+            if match.bad(fn, 'No such file in rev ' + str(self)) and match(fn):
+                yield fn
+
 class filectx(object):
     """A filecontext object makes access to data related to a particular
        filerevision convenient."""
@@ -572,6 +593,10 @@
         """return the ancestor context of self and c2"""
         return self._parents[0].ancestor(c2) # punt on two parents for now
 
+    def walk(self, match):
+        for src, fn, st in self._repo.dirstate.walk(match, True, False):
+            yield fn
+
 class workingfilectx(filectx):
     """A workingfilectx object makes access to data related to a particular
        file in the working directory convenient."""
@@ -693,6 +718,9 @@
     def __str__(self):
         return str(self._parents[0]) + "+"
 
+    def __int__(self):
+        return self._rev
+
     def __nonzero__(self):
         return True
 
--- a/mercurial/hgweb/hgweb_mod.py	Wed Jul 02 10:58:27 2008 +0200
+++ b/mercurial/hgweb/hgweb_mod.py	Wed Jul 02 11:31:19 2008 +0200
@@ -76,8 +76,7 @@
 
     def __call__(self, env, respond):
         req = wsgirequest(env, respond)
-        self.run_wsgi(req)
-        return req
+        return self.run_wsgi(req)
 
     def run_wsgi(self, req):
 
@@ -90,10 +89,9 @@
         cmd = req.form.get('cmd', [''])[0]
         if cmd and cmd in protocol.__all__:
             if cmd in perms and not self.check_perm(req, perms[cmd]):
-                return
+                return []
             method = getattr(protocol, cmd)
-            method(self.repo, req)
-            return
+            return method(self.repo, req)
 
         # work with CGI variables to create coherent structure
         # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME
@@ -171,19 +169,20 @@
 
             req.write(content)
             del tmpl
+            return ''.join(content),
 
         except revlog.LookupError, err:
             req.respond(HTTP_NOT_FOUND, ctype)
             msg = str(err)
             if 'manifest' not in msg:
                 msg = 'revision not found: %s' % err.name
-            req.write(tmpl('error', error=msg))
+            return ''.join(tmpl('error', error=msg)),
         except (RepoError, revlog.RevlogError), inst:
             req.respond(HTTP_SERVER_ERROR, ctype)
-            req.write(tmpl('error', error=str(inst)))
+            return ''.join(tmpl('error', error=str(inst))),
         except ErrorResponse, inst:
             req.respond(inst.code, ctype)
-            req.write(tmpl('error', error=inst.message))
+            return ''.join(tmpl('error', error=inst.message)),
 
     def templater(self, req):
 
--- a/mercurial/hgweb/hgwebdir_mod.py	Wed Jul 02 10:58:27 2008 +0200
+++ b/mercurial/hgweb/hgwebdir_mod.py	Wed Jul 02 11:31:19 2008 +0200
@@ -70,8 +70,7 @@
 
     def __call__(self, env, respond):
         req = wsgirequest(env, respond)
-        self.run_wsgi(req)
-        return req
+        return self.run_wsgi(req)
 
     def run_wsgi(self, req):
 
@@ -90,14 +89,12 @@
                         fname = virtual[7:]
                     else:
                         fname = req.form['static'][0]
-                    req.write(staticfile(static, fname, req))
-                    return
+                    return staticfile(static, fname, req),
 
                 # top-level index
                 elif not virtual:
                     req.respond(HTTP_OK, ctype)
-                    req.write(self.makeindex(req, tmpl))
-                    return
+                    return ''.join(self.makeindex(req, tmpl)),
 
                 # nested indexes and hgwebs
 
@@ -108,8 +105,7 @@
                         req.env['REPO_NAME'] = virtual
                         try:
                             repo = hg.repository(self.parentui, real)
-                            hgweb(repo).run_wsgi(req)
-                            return
+                            return hgweb(repo).run_wsgi(req)
                         except IOError, inst:
                             msg = inst.strerror
                             raise ErrorResponse(HTTP_SERVER_ERROR, msg)
@@ -120,8 +116,7 @@
                     subdir = virtual + '/'
                     if [r for r in repos if r.startswith(subdir)]:
                         req.respond(HTTP_OK, ctype)
-                        req.write(self.makeindex(req, tmpl, subdir))
-                        return
+                        return ''.join(self.makeindex(req, tmpl, subdir)),
 
                     up = virtual.rfind('/')
                     if up < 0:
@@ -130,11 +125,11 @@
 
                 # prefixes not found
                 req.respond(HTTP_NOT_FOUND, ctype)
-                req.write(tmpl("notfound", repo=virtual))
+                return ''.join(tmpl("notfound", repo=virtual)),
 
             except ErrorResponse, err:
                 req.respond(err.code, ctype)
-                req.write(tmpl('error', error=err.message or ''))
+                return ''.join(tmpl('error', error=err.message or '')),
         finally:
             tmpl = None
 
--- a/mercurial/hgweb/protocol.py	Wed Jul 02 10:58:27 2008 +0200
+++ b/mercurial/hgweb/protocol.py	Wed Jul 02 11:31:19 2008 +0200
@@ -30,12 +30,12 @@
         success = 0
     resp = "%s %s\n" % (success, r)
     req.respond(HTTP_OK, HGTYPE, length=len(resp))
-    req.write(resp)
+    yield resp
 
 def heads(repo, req):
     resp = " ".join(map(hex, repo.heads())) + "\n"
     req.respond(HTTP_OK, HGTYPE, length=len(resp))
-    req.write(resp)
+    yield resp
 
 def branches(repo, req):
     nodes = []
@@ -46,7 +46,7 @@
         resp.write(" ".join(map(hex, b)) + "\n")
     resp = resp.getvalue()
     req.respond(HTTP_OK, HGTYPE, length=len(resp))
-    req.write(resp)
+    yield resp
 
 def between(repo, req):
     if 'pairs' in req.form:
@@ -57,7 +57,7 @@
         resp.write(" ".join(map(hex, b)) + "\n")
     resp = resp.getvalue()
     req.respond(HTTP_OK, HGTYPE, length=len(resp))
-    req.write(resp)
+    yield resp
 
 def changegroup(repo, req):
     req.respond(HTTP_OK, HGTYPE)
@@ -72,9 +72,9 @@
         chunk = f.read(4096)
         if not chunk:
             break
-        req.write(z.compress(chunk))
+        yield z.compress(chunk)
 
-    req.write(z.flush())
+    yield z.flush()
 
 def changegroupsubset(repo, req):
     req.respond(HTTP_OK, HGTYPE)
@@ -92,9 +92,9 @@
         chunk = f.read(4096)
         if not chunk:
             break
-        req.write(z.compress(chunk))
+        yield z.compress(chunk)
 
-    req.write(z.flush())
+    yield z.flush()
 
 def capabilities(repo, req):
     caps = ['lookup', 'changegroupsubset']
@@ -104,23 +104,11 @@
         caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
     rsp = ' '.join(caps)
     req.respond(HTTP_OK, HGTYPE, length=len(rsp))
-    req.write(rsp)
+    yield rsp
 
 def unbundle(repo, req):
 
-    def bail(response, headers={}):
-        length = int(req.env.get('CONTENT_LENGTH', 0))
-        for s in util.filechunkiter(req, limit=length):
-            # drain incoming bundle, else client will not see
-            # response when run outside cgi script
-            pass
-
-        status = headers.pop('status', HTTP_OK)
-        req.header(headers.items())
-        req.respond(status, HGTYPE)
-        req.write('0\n')
-        req.write(response)
-
+    errorfmt = '0\n%s\n'
     proto = req.env.get('wsgi.url_scheme') or 'http'
     their_heads = req.form['heads'][0].split(' ')
 
@@ -130,8 +118,13 @@
 
     # fail early if possible
     if not check_heads():
-        bail('unsynced changes\n')
-        return
+        length = int(req.env.get('CONTENT_LENGTH', 0))
+        for s in util.filechunkiter(req, limit=length):
+            # drain incoming bundle, else client will not see
+            # response when run outside cgi script
+            pass
+        req.respond(HTTP_OK, HGTYPE)
+        return errorfmt % 'unsynced changes',
 
     req.respond(HTTP_OK, HGTYPE)
 
@@ -149,9 +142,7 @@
             lock = repo.lock()
             try:
                 if not check_heads():
-                    req.write('0\n')
-                    req.write('unsynced changes\n')
-                    return
+                    return errorfmt % 'unsynced changes',
 
                 fp.seek(0)
                 header = fp.read(6)
@@ -177,15 +168,12 @@
                 finally:
                     val = sys.stdout.getvalue()
                     sys.stdout, sys.stderr = oldio
-                req.write('%d\n' % ret)
-                req.write(val)
+                return '%d\n%s' % (ret, val),
             finally:
                 del lock
         except ValueError, inst:
-            req.write('0\n')
-            req.write(str(inst) + '\n')
+            return errorfmt % inst,
         except (OSError, IOError), inst:
-            req.write('0\n')
             filename = getattr(inst, 'filename', '')
             # Don't send our filesystem layout to the client
             if filename.startswith(repo.root):
@@ -198,7 +186,7 @@
             else:
                 code = HTTP_SERVER_ERROR
             req.respond(code)
-            req.write('%s: %s\n' % (error, filename))
+            return '0\n%s: %s\n' % (error, filename),
     finally:
         fp.close()
         os.unlink(tempname)
@@ -206,3 +194,4 @@
 def stream_out(repo, req):
     req.respond(HTTP_OK, HGTYPE)
     streamclone.stream_out(repo, req, untrusted=True)
+    return []
--- a/mercurial/hgweb/server.py	Wed Jul 02 10:58:27 2008 +0200
+++ b/mercurial/hgweb/server.py	Wed Jul 02 11:31:19 2008 +0200
@@ -122,7 +122,8 @@
         self.saved_headers = []
         self.sent_headers = False
         self.length = None
-        self.server.application(env, self._start_response)
+        for chunk in self.server.application(env, self._start_response):
+            self._write(chunk)
 
     def send_headers(self):
         if not self.saved_status:
--- a/mercurial/httprepo.py	Wed Jul 02 10:58:27 2008 +0200
+++ b/mercurial/httprepo.py	Wed Jul 02 11:31:19 2008 +0200
@@ -268,6 +268,7 @@
 
         # 1.0 here is the _protocol_ version
         opener.addheaders = [('User-agent', 'mercurial/proto-1.0')]
+        opener.addheaders.append(('Accept', 'application/mercurial-0.1'))
         urllib2.install_opener(opener)
 
     def url(self):
--- a/mercurial/localrepo.py	Wed Jul 02 10:58:27 2008 +0200
+++ b/mercurial/localrepo.py	Wed Jul 02 11:31:19 2008 +0200
@@ -941,27 +941,7 @@
         changeset, finding all files matched by the match
         function
         '''
-
-        if node:
-            fdict = dict.fromkeys(match.files())
-            # for dirstate.walk, files=['.'] means "walk the whole tree".
-            # follow that here, too
-            fdict.pop('.', None)
-            for fn in self[node]:
-                for ffn in fdict:
-                    # match if the file is the exact name or a directory
-                    if ffn == fn or fn.startswith("%s/" % ffn):
-                        del fdict[ffn]
-                        break
-                if match(fn):
-                    yield fn
-            for fn in util.sort(fdict):
-                if match.bad(fn, 'No such file in rev ' + short(node)) \
-                        and match(fn):
-                    yield fn
-        else:
-            for src, fn, st in self.dirstate.walk(match, True, False):
-                yield fn
+        return self[node].walk(match)
 
     def status(self, node1=None, node2=None, match=None,
                ignored=False, clean=False, unknown=False):
--- a/mercurial/manifest.py	Wed Jul 02 10:58:27 2008 +0200
+++ b/mercurial/manifest.py	Wed Jul 02 11:31:19 2008 +0200
@@ -119,16 +119,16 @@
             return "".join([struct.pack(">lll", d[0], d[1], len(d[2])) + d[2]
                             for d in x ])
 
-        def checkforbidden(f):
-            if '\n' in f or '\r' in f:
-                raise RevlogError(_("'\\n' and '\\r' disallowed in filenames"))
+        def checkforbidden(l):
+            for f in l:
+                if '\n' in f or '\r' in f:
+                    raise RevlogError(_("'\\n' and '\\r' disallowed in filenames"))
 
         # if we're using the listcache, make sure it is valid and
         # parented by the same node we're diffing against
         if not (changed and self.listcache and p1 and self.mapcache[0] == p1):
             files = util.sort(map)
-            for f in files:
-                checkforbidden(f)
+            checkforbidden(files)
 
             # if this is changed to support newlines in filenames,
             # be sure to check the templates/ dir again (especially *-raw.tmpl)
@@ -139,8 +139,7 @@
         else:
             addlist = self.listcache
 
-            for f in changed[0]:
-                checkforbidden(f)
+            checkforbidden(changed[0])
             # combine the changed lists into one list for sorting
             work = [[x, 0] for x in changed[0]]
             work[len(work):] = [[x, 1] for x in changed[1]]
--- a/mercurial/templater.py	Wed Jul 02 10:58:27 2008 +0200
+++ b/mercurial/templater.py	Wed Jul 02 11:31:19 2008 +0200
@@ -81,18 +81,18 @@
     def __contains__(self, key):
         return key in self.cache or key in self.map
 
-    def __call__(self, t, **map):
-        '''perform expansion.
-        t is name of map element to expand.
-        map is added elements to use during expansion.'''
+    def _template(self, t):
+        '''Get the template for the given template name. Use a local cache.'''
         if not t in self.cache:
             try:
                 self.cache[t] = file(self.map[t]).read()
             except IOError, inst:
                 raise IOError(inst.args[0], _('template file %s: %s') %
                               (self.map[t], inst.args[1]))
-        tmpl = self.cache[t]
+        return self.cache[t]
 
+    def _process(self, tmpl, map):
+        '''Render a template. Returns a generator.'''
         while tmpl:
             m = self.template_re.search(tmpl)
             if not m:
@@ -119,13 +119,34 @@
                 lm = map.copy()
                 for i in v:
                     lm.update(i)
-                    yield self(format, **lm)
+                    t = self._template(format)
+                    yield self._process(t, lm)
             else:
                 if fl:
                     for f in fl.split("|")[1:]:
                         v = self.filters[f](v)
                 yield v
 
+    def __call__(self, t, **map):
+        '''Perform expansion. t is name of map element to expand. map contains
+        added elements for use during expansion. Is a generator.'''
+        tmpl = self._template(t)
+        iters = [self._process(tmpl, map)]
+        while iters:
+            try:
+                item = iters[0].next()
+            except StopIteration:
+                iters.pop(0)
+                continue
+            if isinstance(item, str):
+                yield item
+            elif item is None:
+                yield ''
+            elif hasattr(item, '__iter__'):
+                iters.insert(0, iter(item))
+            else:
+                yield str(item)
+
 def templatepath(name=None):
     '''return location of template file or directory (if no name).
     returns None if not found.'''
--- a/setup.py	Wed Jul 02 10:58:27 2008 +0200
+++ b/setup.py	Wed Jul 02 11:31:19 2008 +0200
@@ -129,7 +129,7 @@
                    [os.path.join(root, file_) for file_ in files])
                   for root, dirs, files in os.walk('templates')],
       cmdclass=cmdclass,
-      options=dict(py2exe=dict(packages=['hgext']),
+      options=dict(py2exe=dict(packages=['hgext', 'email']),
                    bdist_mpkg=dict(zipdist=True,
                                    license='COPYING',
                                    readme='contrib/macosx/Readme.html',
--- a/tests/test-acl.out	Wed Jul 02 10:58:27 2008 +0200
+++ b/tests/test-acl.out	Wed Jul 02 11:31:19 2008 +0200
@@ -58,8 +58,6 @@
 adding quux/file.py revisions
 added 3 changesets with 3 changes to 3 files
 calling hook pretxnchangegroup.acl: hgext.acl.hook
-acl: acl.allow not enabled
-acl: acl.deny not enabled
 acl: changes have source "push" - skipping
 updating the branch cache
 rolling back last transaction
--- a/tests/test-hgweb-commands	Wed Jul 02 10:58:27 2008 +0200
+++ b/tests/test-hgweb-commands	Wed Jul 02 11:31:19 2008 +0200
@@ -34,6 +34,7 @@
 echo % Overviews
 "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/tags/?style=atom' | sed "s/http:\/\/[^/]*\//http:\/\/127.0.0.1\//"
 "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/summary/?style=gitweb' | sed "s/[0-9]* years ago/long ago/g"
+"$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/graph/?style=gitweb' | sed "s/[0-9]* years/long/g"
 
 echo % capabilities
 "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=capabilities'
Binary file tests/test-hgweb-commands.out has changed
--- a/tests/test-hgweb-no-path-info	Wed Jul 02 10:58:27 2008 +0200
+++ b/tests/test-hgweb-no-path-info	Wed Jul 02 11:31:19 2008 +0200
@@ -43,15 +43,17 @@
 
 output = StringIO()
 env['QUERY_STRING'] = 'style=atom'
-hgweb('.', name = 'repo')(env, startrsp)
-print output.getvalue()
+content = hgweb('.', name = 'repo')(env, startrsp)
+sys.stdout.write(output.getvalue())
+sys.stdout.write(''.join(content))
 print '---- ERRORS'
 print errors.getvalue()
 
 output = StringIO()
 env['QUERY_STRING'] = 'style=raw'
-hgwebdir({'repo': '.'})(env, startrsp)
-print output.getvalue()
+content = hgwebdir({'repo': '.'})(env, startrsp)
+sys.stdout.write(output.getvalue())
+sys.stdout.write(''.join(content))
 print '---- ERRORS'
 print errors.getvalue()
 EOF
--- a/tests/test-hgweb-no-path-info.out	Wed Jul 02 10:58:27 2008 +0200
+++ b/tests/test-hgweb-no-path-info.out	Wed Jul 02 11:31:19 2008 +0200
@@ -35,7 +35,6 @@
  </entry>
 
 </feed>
-
 ---- ERRORS
 
 ---- HEADERS
@@ -45,6 +44,5 @@
 
 repo/
 
-
 ---- ERRORS
 
--- a/tests/test-hgweb-no-request-uri	Wed Jul 02 10:58:27 2008 +0200
+++ b/tests/test-hgweb-no-request-uri	Wed Jul 02 11:31:19 2008 +0200
@@ -44,32 +44,36 @@
 output = StringIO()
 env['PATH_INFO'] = '/'
 env['QUERY_STRING'] = 'style=atom'
-hgweb('.', name = 'repo')(env, startrsp)
-print output.getvalue()
+content = hgweb('.', name = 'repo')(env, startrsp)
+sys.stdout.write(output.getvalue())
+sys.stdout.write(''.join(content))
 print '---- ERRORS'
 print errors.getvalue()
 
 output = StringIO()
 env['PATH_INFO'] = '/file/tip/'
 env['QUERY_STRING'] = 'style=raw'
-hgweb('.', name = 'repo')(env, startrsp)
-print output.getvalue()
+content = hgweb('.', name = 'repo')(env, startrsp)
+sys.stdout.write(output.getvalue())
+sys.stdout.write(''.join(content))
 print '---- ERRORS'
 print errors.getvalue()
 
 output = StringIO()
 env['PATH_INFO'] = '/'
 env['QUERY_STRING'] = 'style=raw'
-hgwebdir({'repo': '.'})(env, startrsp)
-print output.getvalue()
+content = hgwebdir({'repo': '.'})(env, startrsp)
+sys.stdout.write(output.getvalue())
+sys.stdout.write(''.join(content))
 print '---- ERRORS'
 print errors.getvalue()
 
 output = StringIO()
 env['PATH_INFO'] = '/repo/file/tip/'
 env['QUERY_STRING'] = 'style=raw'
-hgwebdir({'repo': '.'})(env, startrsp)
-print output.getvalue()
+content = hgwebdir({'repo': '.'})(env, startrsp)
+sys.stdout.write(output.getvalue())
+sys.stdout.write(''.join(content))
 print '---- ERRORS'
 print errors.getvalue()
 EOF
--- a/tests/test-hgweb-no-request-uri.out	Wed Jul 02 10:58:27 2008 +0200
+++ b/tests/test-hgweb-no-request-uri.out	Wed Jul 02 11:31:19 2008 +0200
@@ -35,6 +35,24 @@
  </entry>
 
 </feed>
+---- ERRORS
+
+---- HEADERS
+200 Script output follows
+---- DATA
+[('Content-Type', 'text/plain; charset=ascii')]
+
+-rw-r--r-- 4 bar
+
+
+---- ERRORS
+
+---- HEADERS
+200 Script output follows
+---- DATA
+[('Content-Type', 'text/plain; charset=ascii')]
+
+/repo/
 
 ---- ERRORS
 
@@ -46,27 +64,5 @@
 -rw-r--r-- 4 bar
 
 
-
 ---- ERRORS
 
----- HEADERS
-200 Script output follows
----- DATA
-[('Content-Type', 'text/plain; charset=ascii')]
-
-/repo/
-
-
----- ERRORS
-
----- HEADERS
-200 Script output follows
----- DATA
-[('Content-Type', 'text/plain; charset=ascii')]
-
--rw-r--r-- 4 bar
-
-
-
----- ERRORS
-