Пример #1
0
    def add(self, text, meta, transaction, linknode, p1=None, p2=None):
        hashtext = text

        # hash with the metadata, like in vanilla filelogs
        hashtext = shallowutil.createrevlogtext(
            text, meta.get("copy"), meta.get("copyrev")
        )
        node = revlog.hash(hashtext, p1, p2)
        return self.addrevision(hashtext, transaction, linknode, p1, p2, node=node)
Пример #2
0
    def addrevision(
        self,
        text,
        transaction,
        linknode,
        p1,
        p2,
        cachedelta=None,
        node=None,
        flags=revlog.REVIDX_DEFAULT_FLAGS,
    ):
        # text passed to "addrevision" includes hg filelog metadata header
        if node is None:
            node = revlog.hash(text, p1, p2)

        meta, metaoffset = filelog.parsemeta(text)
        rawtext, validatehash = self._processflags(text, flags, "write")

        if len(rawtext) > _maxentrysize:
            raise revlog.RevlogError(
                _("%s: size of %s exceeds maximum size of %s")
                % (
                    self.filename,
                    util.bytecount(len(rawtext)),
                    util.bytecount(_maxentrysize),
                )
            )

        return self.addrawrevision(
            rawtext,
            transaction,
            linknode,
            p1,
            p2,
            node,
            flags,
            cachedelta,
            _metatuple=(meta, metaoffset),
        )
Пример #3
0
    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