def commitgraph(self, heads, common): """heads: [node], common: [node] Returns a list of [(node, parents)], parents is a list of node. """ items = self.edenapi.commitgraph(heads, common) shouldtrace = tracing.isenabled(tracing.LEVEL_TRACE) for item in items: node = item["hgid"] parents = item["parents"] if shouldtrace: tracing.trace( "graph node %s %r" % (hex(node), [hex(n) for n in parents]) ) yield node, parents
def known(self, nodes): assert isinstance(nodes, list) stream = self.edenapi.commitknown(nodes) knownnodes = set() # ex. [{'hgid': '11111111111111111111', 'known': {'Ok': False}}] for res in stream: node = res["hgid"] known = unwrap(res["known"], node) if known: knownnodes.add(node) shouldtrace = tracing.isenabled(tracing.LEVEL_TRACE) if shouldtrace: for node in sorted(nodes): tracing.trace("known %s: %s" % (hex(node), node in knownnodes)) return [n in knownnodes for n in nodes]
def addblobs(self, blobs): """blobs: [(type, node, (p1, p2), text)] type: "tree" | "blob" | "commit" """ addcommit = self._inner.addcommit addsha1blob = self._inner.addsha1blob shouldtrace = tracing.isenabled(tracing.LEVEL_TRACE) for btype, node, (p1, p2), text in blobs: data = textwithheader(text, p1, p2) if shouldtrace: tracing.trace("adding %6s %s" % (btype, hex(node))) if btype == "commit": parents = [p for p in (p1, p2) if p != nullid] newnode = addcommit(parents, text) else: assert btype == "blob" or btype == "tree" newnode = addsha1blob(data) assert newnode == node, "SHA1 mismatch" self._flush()