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

Thomas Arendsen Hein thomas at intevation.de
Tue Sep 18 09:22:57 CDT 2012


* 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

Regards,
Thomas

-- 
thomas at intevation.de - http://intevation.de/~thomas/ - OpenPGP key: 0x5816791A
Intevation GmbH, Neuer Graben 17, 49074 Osnabrueck - AG Osnabrueck, HR B 18998
Geschaeftsfuehrer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner


More information about the Mercurial-devel mailing list