def createrevlogtext(text, copyfrom=None, copyrev=None): """returns a string that matches the revlog contents in a traditional revlog """ meta = {} if copyfrom or text.startswith(b"\1\n"): if copyfrom: meta["copy"] = copyfrom meta["copyrev"] = copyrev text = filelog.packmeta(meta, text) return text
def readfromstore(self, text): """Return placeholder instead of actual lfs file.""" p = pointer.deserialize(text) isbinary = bool(int(p.get("x-is-binary", 1))) placeholder = ("This is a placeholder for a large file\n\n" "Original file id: %s\n" "Original file size: %s\n" "Original file is binary: %s\n" % (p["oid"], p.size(), isbinary)) # pack hg filelog metadata hgmeta = p.hgmeta() text = placeholder.encode("utf-8") if hgmeta: text = filelog.packmeta(hgmeta, text) return (text, False)
def readfromstore(self, text): """Read filelog content from local blobstore transform for flagprocessor. Default tranform for flagprocessor, returning contents from blobstore. Returns a 2-typle (text, validatehash) where validatehash is True as the contents of the blobstore should be checked using checkhash. """ p = pointer.deserialize(text) oid = p.oid() store = self.opener.lfslocalblobstore if not store.has(oid): p.filename = getattr(self, "indexfile", None) self.opener.lfsremoteblobstore.readbatch([p], store) text = store.read(oid) # pack hg filelog metadata hgmeta = p.hgmeta() if hgmeta or text.startswith("\1\n"): text = filelog.packmeta(hgmeta, text) return (text, True)
def cmp(self, node, text): """compare text with a given file revision returns True if text is different than what is stored. """ if node == nullid: return True # If it appears to be a redacted file, do a full comparison. Normally # we'd do a flags comparison, but the flags coming from Mononoke in the # tests don't seem to include the redacted flag. if text == constants.REDACTED_MESSAGE: return self.read(node) != text # remotefilectx.cmp uses the size as a shortcircuit. Unfortunately the # size comparison is expensive for lfs files, since reading the size # from the store currently also involves reading the content. # # The content comparison is expensive as well, since we have to load # the content from the store and from disk. Let's just check the # node instead. p1, p2, linknode, copyfrom = self.repo.fileslog.metadatastore.getnodeinfo( self.filename, node ) if copyfrom or text.startswith(b"\1\n"): meta = {} if copyfrom: meta["copy"] = copyfrom meta["copyrev"] = hex(p1) p1 = nullid text = filelog.packmeta(meta, text) newnode = revlog.hash(text, p1, p2) return node != newnode