Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 1199:78ceaf83f28f
Created a class in util called chunkbuffer that buffers reads from an
iterator over strings (aka chunks).
Also added to util (for future use) is a generator function that
iterates over a file n bytes at a time.
Lastly, localrepo was changed to use this new chunkbuffer class when
reading changegroups form the local repository.
author | Eric Hopper <hopper@omnifarious.org> |
---|---|
date | Sun, 04 Sep 2005 14:11:51 -0700 |
parents | 899b619a7eb2 |
children | 5381b0d88e9e |
comparison
equal
deleted
inserted
replaced
1198:66f7d3946109 | 1199:78ceaf83f28f |
---|---|
886 | 886 |
887 cg = self.changegroup(update) | 887 cg = self.changegroup(update) |
888 return remote.addchangegroup(cg) | 888 return remote.addchangegroup(cg) |
889 | 889 |
890 def changegroup(self, basenodes): | 890 def changegroup(self, basenodes): |
891 class genread: | 891 genread = util.chunkbuffer |
892 def __init__(self, generator): | |
893 self.g = generator | |
894 self.buf = "" | |
895 def fillbuf(self): | |
896 self.buf += "".join(self.g) | |
897 | |
898 def read(self, l): | |
899 while l > len(self.buf): | |
900 try: | |
901 self.buf += self.g.next() | |
902 except StopIteration: | |
903 break | |
904 d, self.buf = self.buf[:l], self.buf[l:] | |
905 return d | |
906 | 892 |
907 def gengroup(): | 893 def gengroup(): |
908 nodes = self.newer(basenodes) | 894 nodes = self.newer(basenodes) |
909 | 895 |
910 # construct the link map | 896 # construct the link map |