Mercurial > hg-stable
changeset 12333:44c7dfc2f6a3
bundle: make getchunk() a method
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 18 Sep 2010 18:20:34 -0500 |
parents | 680fe77ab5b8 |
children | 50946802593d |
files | contrib/shrink-revlog.py mercurial/bundlerepo.py mercurial/changegroup.py mercurial/localrepo.py |
diffstat | 4 files changed, 16 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/shrink-revlog.py Fri Sep 17 19:24:29 2010 -0500 +++ b/contrib/shrink-revlog.py Sat Sep 18 18:20:34 2010 -0500 @@ -117,8 +117,7 @@ try: group = util.chunkbuffer(r1.group(order, lookup, progress)) - chunkiter = changegroup.chunkiter(group) - r2.addgroup(chunkiter, unlookup, tr) + r2.addgroup(group.chunks(), unlookup, tr) finally: ui.progress(_('writing'), None)
--- a/mercurial/bundlerepo.py Fri Sep 17 19:24:29 2010 -0500 +++ b/mercurial/bundlerepo.py Sat Sep 18 18:20:34 2010 -0500 @@ -33,7 +33,7 @@ self.bundle = bundle self.basemap = {} def chunkpositer(): - for chunk in changegroup.chunkiter(bundle): + for chunk in bundle.chunks(): pos = bundle.tell() yield chunk, pos - len(chunk) n = len(self) @@ -226,11 +226,11 @@ if not self.bundlefilespos: self.bundle.seek(self.filestart) while 1: - chunk = changegroup.getchunk(self.bundle) + chunk = self.bundle.chunk() if not chunk: break self.bundlefilespos[chunk] = self.bundle.tell() - for c in changegroup.chunkiter(self.bundle): + for c in self.bundle.chunks(): pass if f[0] == '/':
--- a/mercurial/changegroup.py Fri Sep 17 19:24:29 2010 -0500 +++ b/mercurial/changegroup.py Sat Sep 18 18:20:34 2010 -0500 @@ -150,6 +150,10 @@ return self._stream.seek(pos) def tell(self): return self._stream.tell() + def chunks(self, progress=None): + return chunkiter(self, progress) + def chunk(self): + return getchunk(self) class headerlessfixup(object): def __init__(self, fh, h):
--- a/mercurial/localrepo.py Fri Sep 17 19:24:29 2010 -0500 +++ b/mercurial/localrepo.py Sat Sep 18 18:20:34 2010 -0500 @@ -1644,6 +1644,9 @@ if not source: return 0 + if not hasattr(source, 'chunk'): + source = changegroup.unbundle10(source, 'UN') + self.hook('prechangegroup', throw=True, source=srctype, url=url) changesets = files = revisions = 0 @@ -1671,8 +1674,8 @@ total=self.total) self.count += 1 pr = prog() - chunkiter = changegroup.chunkiter(source, progress=pr) - if cl.addgroup(chunkiter, csmap, trp) is None and not emptyok: + if (cl.addgroup(source.chunks(pr), csmap, trp) is None + and not emptyok): raise util.Abort(_("received changelog group is empty")) clend = len(cl) changesets = clend - clstart @@ -1686,12 +1689,11 @@ pr.step = _('manifests') pr.count = 1 pr.total = changesets # manifests <= changesets - chunkiter = changegroup.chunkiter(source, progress=pr) # no need to check for empty manifest group here: # if the result of the merge of 1 and 2 is the same in 3 and 4, # no new manifest will be created and the manifest group will # be empty during the pull - self.manifest.addgroup(chunkiter, revmap, trp) + self.manifest.addgroup(source.chunks(pr), revmap, trp) self.ui.progress(_('manifests'), None) needfiles = {} @@ -1710,15 +1712,14 @@ pr.count = 1 pr.total = efiles while 1: - f = changegroup.getchunk(source) + f = source.chunk() if not f: break self.ui.debug("adding %s revisions\n" % f) pr() fl = self.file(f) o = len(fl) - chunkiter = changegroup.chunkiter(source) - if fl.addgroup(chunkiter, revmap, trp) is None: + if fl.addgroup(source.chunks(), revmap, trp) is None: raise util.Abort(_("received file revlog group is empty")) revisions += len(fl) - o files += 1