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))
def changegroupsubset(self, bases, heads, kind): self.requirecap('changegroupsubset', _('look up remote changes')) bases = encodelist(bases) heads = encodelist(heads) f = self._callcompressable("changegroupsubset", bases=bases, heads=heads) return changegroupmod.cg1unpacker(f, 'UN')
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 not None and 'HG2Y' in bundlecaps: return bundle2.unbundle20(self.ui, f) else: return changegroupmod.cg1unpacker(f, 'UN')
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')
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")
def do_addchangegroup(self): """DEPRECATED""" if not self.lock: self.sendresponse("not locked") return self.sendresponse("") cg = changegroup.cg1unpacker(self.fin, "UN") r = changegroup.addchangegroup(self.repo, cg, "serve", self._client()) self.lock.release() return str(r)
def do_addchangegroup(self): '''DEPRECATED''' if not self.lock: self.sendresponse("not locked") return self.sendresponse("") cg = changegroup.cg1unpacker(self.fin, "UN") r = changegroup.addchangegroup(self.repo, cg, 'serve', self._client()) self.lock.release() return str(r)
def handlechangegroup(op, inpart): """apply a changegroup part on the repo This is a very early implementation that will massive rework before being inflicted to any end-user. """ # Make sure we trigger a transaction creation # # The addchangegroup function will get a transaction object by itself, but # we need to make sure we trigger the creation of a transaction object used # for the whole processing scope. op.gettransaction() cg = changegroup.cg1unpacker(inpart, 'UN') # the source and url passed here are overwritten by the one contained in # the transaction.hookargs argument. So 'bundle2' is a placeholder ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2') op.records.add('changegroup', {'return': ret}) if op.reply is not None: # This is definitly not the final form of this # return. But one need to start somewhere. part = op.reply.newpart('b2x:reply:changegroup') part.addparam('in-reply-to', str(inpart.id), mandatory=False) part.addparam('return', '%i' % ret, mandatory=False) assert not inpart.read()
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 not None and "HG2Y" in bundlecaps: return bundle2.unbundle20(self.ui, f) else: return changegroupmod.cg1unpacker(f, "UN")
def changegroup(self, nodes, kind): n = encodelist(nodes) f = self._callcompressable("changegroup", roots=n) return changegroupmod.cg1unpacker(f, 'UN')