Mercurial > public > mercurial-scm > hg-stable
diff mercurial/bundlerepo.py @ 24073:ff5caa8dfd99
bundlerepo: basic bundle2 support
For bundlerepo to work with bundle2 files, we need to find the part that
contains the bundle's changegroup data and work with that instead of the
entire bundle. Future work can add separate processing for other bundle2
parts.
author | Eric Sumner <ericsumner@fb.com> |
---|---|
date | Fri, 06 Feb 2015 11:27:25 -0800 |
parents | 145b823f5ce7 |
children | 6ddc86eedc3b |
line wrap: on
line diff
--- a/mercurial/bundlerepo.py Thu Feb 05 16:03:26 2015 -0800 +++ b/mercurial/bundlerepo.py Fri Feb 06 11:27:25 2015 -0800 @@ -15,7 +15,7 @@ from i18n import _ import os, tempfile, shutil import changegroup, util, mdiff, discovery, cmdutil, scmutil, exchange -import localrepo, changelog, manifest, filelog, revlog, error, phases +import localrepo, changelog, manifest, filelog, revlog, error, phases, bundle2 class bundlerevlog(revlog.revlog): def __init__(self, opener, indexfile, bundle, linkmapper): @@ -238,6 +238,24 @@ bundlename, self.vfs) + if isinstance(self.bundle, bundle2.unbundle20): + cgparts = [part for part in self.bundle.iterparts() + if (part.type == 'b2x:changegroup') + and (part.params.get('version', '01') + in changegroup.packermap)] + + if not cgparts: + raise util.Abort('No changegroups found') + version = cgparts[0].params.get('version', '01') + cgparts = [p for p in cgparts + if p.params.get('version', '01') == version] + if len(cgparts) > 1: + raise NotImplementedError("Can't process multiple changegroups") + part = cgparts[0] + + part.seek(0) + self.bundle = changegroup.packermap[version][1](part, 'UN') + # dict with the mapping 'filename' -> position in the bundle self.bundlefilespos = {}