コード例 #1
0
def readbundle(ui, fh, fname, vfs=None):
    header = changegroup.readexactly(fh, 4)

    alg = None
    if not fname:
        fname = "stream"
        if not header.startswith('HG') and header.startswith('\0'):
            fh = changegroup.headerlessfixup(fh, header)
            header = "HG10"
            alg = 'UN'
    elif vfs:
        fname = vfs.join(fname)

    magic, version = header[0:2], header[2:4]

    if magic != 'HG':
        raise util.Abort(_('%s: not a Mercurial bundle') % fname)
    if version == '10':
        if alg is None:
            alg = changegroup.readexactly(fh, 2)
        return changegroup.cg1unpacker(fh, alg)
    elif version == '2Y':
        return bundle2.unbundle20(ui, fh, header=magic + version)
    else:
        raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
コード例 #2
0
def readbundle(ui, fh, fname, vfs=None):
    header = changegroup.readexactly(fh, 4)

    alg = None
    if not fname:
        fname = "stream"
        if not header.startswith('HG') and header.startswith('\0'):
            fh = changegroup.headerlessfixup(fh, header)
            header = "HG10"
            alg = 'UN'
    elif vfs:
        fname = vfs.join(fname)

    magic, version = header[0:2], header[2:4]

    if magic != 'HG':
        raise util.Abort(_('%s: not a Mercurial bundle') % fname)
    if version == '10':
        if alg is None:
            alg = changegroup.readexactly(fh, 2)
        return changegroup.unbundle10(fh, alg)
    elif version == '2X':
        return bundle2.unbundle20(ui, fh, header=magic + version)
    else:
        raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
コード例 #3
0
ファイル: bundle2.py プロジェクト: RayFerr000/PLTL
def getunbundler(ui, fp, header=None):
    """return a valid unbundler object for a given header"""
    if header is None:
        header = changegroup.readexactly(fp, 4)
    magic, version = header[0:2], header[2:4]
    if magic != 'HG':
        raise util.Abort(_('not a Mercurial bundle'))
    unbundlerclass = formatmap.get(version)
    if unbundlerclass is None:
        raise util.Abort(_('unknown bundle version %s') % version)
    unbundler = unbundlerclass(ui, fp)
    ui.debug('start processing of %s stream\n' % header)
    return unbundler
コード例 #4
0
 def _readexact(self, size):
     """read exactly <size> bytes from the stream"""
     return changegroup.readexactly(self._fp, size)
コード例 #5
0
 def _readexact(self, size):
     """read exactly <size> bytes from the stream"""
     return changegroup.readexactly(self._fp, size)