[PATCH 03 of 10] wireproto: don't audit local paths during stream_out

Matt Mackall mpm at selenic.com
Tue Sep 18 14:32:16 CDT 2012


On Tue, 2012-09-18 at 16:22 +0200, Thomas Arendsen Hein wrote:
> * Bryan O'Sullivan <bos at serpentine.com> [20120913 21:02]:
> > # HG changeset patch
> > # User Bryan O'Sullivan <bryano at fb.com>
> > # Date 1347562629 25200
> > # Node ID f85d5c5b428594aeccc4ce0a81786f53eea9039c
> > # Parent  d89e56d72ecf0ef69b1650aac774667297969622
> > wireproto: don't audit local paths during stream_out
> > 
> > Auditing at this stage is both pointless (they're already trusted by
> > the local repo) and expensive. Skipping the audits improves stream_out
> > performance by about 15%.
> > 
> > diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
> > --- a/mercurial/wireproto.py
> > +++ b/mercurial/wireproto.py
> > @@ -545,12 +545,21 @@
> >          repo.ui.debug('%d files, %d bytes to transfer\n' %
> >                        (len(entries), total_bytes))
> >          yield '%d %d\n' % (len(entries), total_bytes)
> > -        for name, size in entries:
> > -            repo.ui.debug('sending %s (%d bytes)\n' % (name, size))
> > -            # partially encode name over the wire for backwards compat
> > -            yield '%s\0%d\n' % (store.encodedir(name), size)
> > -            for chunk in util.filechunkiter(repo.sopener(name), limit=size):
> > -                yield chunk
> > +
> > +        sopener = repo.sopener
> > +
> > +        try:
> > +            oldaudit = sopener.mustaudit
> > +            sopener.mustaudit = False
> > +
> > +            for name, size in entries:
> > +                repo.ui.debug('sending %s (%d bytes)\n' % (name, size))
> > +                # partially encode name over the wire for backwards compat
> > +                yield '%s\0%d\n' % (store.encodedir(name), size)
> > +                for chunk in util.filechunkiter(sopener(name), limit=size):
> > +                    yield chunk
> > +        finally:
> > +            sopener.mustaudit = oldaudit
> >  
> >      return streamres(streamer(repo, entries, total_bytes))
> >  
> 
> This causes a traceback on Python 2.4:
> SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause

We can catch this in check-code, much like we currently catch
try/except/finally:

http://www.selenic.com/hg/file/55724f42fa14/contrib/check-code.py#l139

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list