Пример #1
0
    def unbundle(self, cg, heads, source):
        '''Send cg (a readable file-like object representing the
        changegroup to push, typically a chunkbuffer object) to the
        remote server as a bundle.

        When pushing a bundle10 stream, return an integer indicating the
        result of the push (see localrepository.addchangegroup()).

        When pushing a bundle20 stream, return a bundle20 stream.'''

        if heads != ['force'] and self.capable('unbundlehash'):
            heads = encodelist(
                ['hashed',
                 util.sha1(''.join(sorted(heads))).digest()])
        else:
            heads = encodelist(heads)

        if util.safehasattr(cg, 'deltaheader'):
            # this a bundle10, do the old style call sequence
            ret, output = self._callpush("unbundle", cg, heads=heads)
            if ret == "":
                raise error.ResponseError(_('push failed:'), output)
            try:
                ret = int(ret)
            except ValueError:
                raise error.ResponseError(
                    _('push failed (unexpected response):'), ret)

            for l in output.splitlines(True):
                self.ui.status(_('remote: '), l)
        else:
            # bundle2 push. Send a stream, fetch a stream.
            stream = self._calltwowaystream('unbundle', cg, heads=heads)
            ret = bundle2.getunbundler(self.ui, stream)
        return ret
Пример #2
0
 def getbundle(self, source, **kwargs):
     self.requirecap('getbundle', _('look up remote changes'))
     opts = {}
     bundlecaps = kwargs.get('bundlecaps')
     if bundlecaps is not None:
         kwargs['bundlecaps'] = sorted(bundlecaps)
     else:
         bundlecaps = ()  # kwargs could have it to None
     for key, value in kwargs.iteritems():
         if value is None:
             continue
         keytype = gboptsmap.get(key)
         if keytype is None:
             assert False, 'unexpected'
         elif keytype == 'nodes':
             value = encodelist(value)
         elif keytype in ('csv', 'scsv'):
             value = ','.join(value)
         elif keytype == 'boolean':
             value = '%i' % bool(value)
         elif keytype != 'plain':
             raise KeyError('unknown getbundle option type %s' % keytype)
         opts[key] = value
     f = self._callcompressable("getbundle", **opts)
     if any((cap.startswith('HG2') for cap in bundlecaps)):
         return bundle2.getunbundler(self.ui, f)
     else:
         return changegroupmod.cg1unpacker(f, 'UN')
Пример #3
0
 def getbundle(self, source, **kwargs):
     self.requirecap("getbundle", _("look up remote changes"))
     opts = {}
     bundlecaps = kwargs.get("bundlecaps")
     if bundlecaps is not None:
         kwargs["bundlecaps"] = sorted(bundlecaps)
     else:
         bundlecaps = ()  # kwargs could have it to None
     for key, value in kwargs.iteritems():
         if value is None:
             continue
         keytype = gboptsmap.get(key)
         if keytype is None:
             assert False, "unexpected"
         elif keytype == "nodes":
             value = encodelist(value)
         elif keytype in ("csv", "scsv"):
             value = ",".join(value)
         elif keytype == "boolean":
             value = "%i" % bool(value)
         elif keytype != "plain":
             raise KeyError("unknown getbundle option type %s" % keytype)
         opts[key] = value
     f = self._callcompressable("getbundle", **opts)
     if any((cap.startswith("HG2") for cap in bundlecaps)):
         return bundle2.getunbundler(self.ui, f)
     else:
         return changegroupmod.cg1unpacker(f, "UN")
Пример #4
0
    def unbundle(self, cg, heads, source):
        """Send cg (a readable file-like object representing the
        changegroup to push, typically a chunkbuffer object) to the
        remote server as a bundle.

        When pushing a bundle10 stream, return an integer indicating the
        result of the push (see localrepository.addchangegroup()).

        When pushing a bundle20 stream, return a bundle20 stream."""

        if heads != ["force"] and self.capable("unbundlehash"):
            heads = encodelist(["hashed", util.sha1("".join(sorted(heads))).digest()])
        else:
            heads = encodelist(heads)

        if util.safehasattr(cg, "deltaheader"):
            # this a bundle10, do the old style call sequence
            ret, output = self._callpush("unbundle", cg, heads=heads)
            if ret == "":
                raise error.ResponseError(_("push failed:"), output)
            try:
                ret = int(ret)
            except ValueError:
                raise error.ResponseError(_("push failed (unexpected response):"), ret)

            for l in output.splitlines(True):
                self.ui.status(_("remote: "), l)
        else:
            # bundle2 push. Send a stream, fetch a stream.
            stream = self._calltwowaystream("unbundle", cg, heads=heads)
            ret = bundle2.getunbundler(self.ui, stream)
        return ret
Пример #5
0
 def getbundle(self, source, **kwargs):
     self.requirecap('getbundle', _('look up remote changes'))
     opts = {}
     for key, value in kwargs.iteritems():
         if value is None:
             continue
         keytype = gboptsmap.get(key)
         if keytype is None:
             assert False, 'unexpected'
         elif keytype == 'nodes':
             value = encodelist(value)
         elif keytype == 'csv':
             value = ','.join(value)
         elif keytype == 'boolean':
             value = '%i' % bool(value)
         elif keytype != 'plain':
             raise KeyError('unknown getbundle option type %s'
                            % keytype)
         opts[key] = value
     f = self._callcompressable("getbundle", **opts)
     bundlecaps = kwargs.get('bundlecaps')
     if bundlecaps is None:
         bundlecaps = () # kwargs could have it to None
     if util.any((cap.startswith('HG2') for cap in bundlecaps)):
         return bundle2.getunbundler(self.ui, f)
     else:
         return changegroupmod.cg1unpacker(f, 'UN')