[patch 4/9] Allow the changegroup generator to completely load the buffer.

Matt Mackall mpm at selenic.com
Sun Jul 17 02:24:11 UTC 2005


On Sat, Jul 16, 2005 at 03:22:03PM -0400, Chris Mason wrote:
> # HG changeset patch
> # User mason at suse.com
> 
> Allow the changegroup generator to completely load the buffer.
> 
> This makes is possible to delete or truncate away revisions and still
> use the changegroup later.

This is a little odd. Can't we do this outside of this function simply
by looping on read()?

> Index: mine/mercurial/hg.py
> ===================================================================
> --- mine.orig/mercurial/hg.py	2005-07-16 08:46:35.000000000 -0400
> +++ mine/mercurial/hg.py	2005-07-16 08:46:45.000000000 -0400
> @@ -1150,6 +1150,12 @@ class localrepository:
>              def __init__(self, generator):
>                  self.g = generator
>                  self.buf = ""
> +            def fillbuf(self):
> +                while True:
> +                    try:
> +                        self.buf += self.g.next()
> +                    except StopIteration:
> +                        break

This is the classic O(n^2) Python mistake.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial mailing list