Example #1
0
    def revdiff(self, rev1, rev2):
        """return or calculate a delta between two revisions"""
        if rev1 != nullrev and self.deltaparent(rev2) == rev1:
            return self._chunk(rev2)

        return mdiff.textdiff(self.revision(self.node(rev1)),
                              self.revision(self.node(rev2)))
Example #2
0
    def revdiff(self, rev1, rev2):
        """return or calculate a delta between two revisions"""
        if rev1 != nullrev and self.deltaparent(rev2) == rev1:
            return self._chunk(rev2)

        return mdiff.textdiff(self.revision(self.node(rev1)),
                              self.revision(self.node(rev2)))
Example #3
0
    def revdiff(self, rev1, rev2):
        """return or calculate a delta between two revisions"""
        if rev1 + 1 == rev2 and self.base(rev1) == self.base(rev2):
            return self.chunk(rev2)

        return mdiff.textdiff(self.revision(self.node(rev1)),
                              self.revision(self.node(rev2)))
Example #4
0
    def revdiff(self, rev1, rev2):
        """return or calculate a delta between two revisions"""
        if rev1 + 1 == rev2 and self.base(rev1) == self.base(rev2):
            return self.chunk(rev2)

        return mdiff.textdiff(self.revision(self.node(rev1)),
                              self.revision(self.node(rev2)))
Example #5
0
    def revdiff(self, rev1, rev2):
        """return or calculate a delta between two revisions"""
        if rev1 > self.repotiprev and rev2 > self.repotiprev:
            return self.revlog2.revdiff(self.revlog2.rev(self.node(rev1)),
                                        self.revlog2.rev(self.node(rev2)))
        elif rev1 <= self.repotiprev and rev2 <= self.repotiprev:
            return self.baserevdiff(rev1, rev2)

        return mdiff.textdiff(self.revision(self.node(rev1)),
                              self.revision(self.node(rev2)))
    def revdiff(self, rev1, rev2):
        """return or calculate a delta between two revisions"""
        if rev1 > self.repotiprev and rev2 > self.repotiprev:
            return self.revlog2.revdiff(
                self.revlog2.rev(self.node(rev1)),
                self.revlog2.rev(self.node(rev2)))
        elif rev1 <= self.repotiprev and rev2 <= self.repotiprev:
            return revlog.revlog.revdiff(self, rev1, rev2)

        return mdiff.textdiff(self.revision(self.node(rev1)),
                              self.revision(self.node(rev2)))
    def revdiff(self, rev1, rev2):
        """return or calculate a delta between two revisions"""
        if rev1 > self.repotiprev and rev2 > self.repotiprev:
            # hot path for bundle
            revb = self.index[rev2][3]
            if revb == rev1:
                return self._chunk(rev2)
        elif rev1 <= self.repotiprev and rev2 <= self.repotiprev:
            return revlog.revlog.revdiff(self, rev1, rev2)

        return mdiff.textdiff(self.revision(self.node(rev1)), self.revision(self.node(rev2)))
Example #8
0
    def revdiff(self, rev1, rev2):
        """return or calculate a delta between two revisions"""
        if rev1 > self.repotiprev and rev2 > self.repotiprev:
            # hot path for bundle
            revb = self.index[rev2][3]
            if revb == rev1:
                return self._chunk(rev2)
        elif rev1 <= self.repotiprev and rev2 <= self.repotiprev:
            return revlog.revlog.revdiff(self, rev1, rev2)

        return mdiff.textdiff(self.revision(self.node(rev1)),
                              self.revision(self.node(rev2)))
Example #9
0
    def revdiff(self, rev1, rev2):
        """return or calculate a delta between two revisions"""
        if self.inbundle(rev1) and self.inbundle(rev2):
            # hot path for bundle
            revb = self.rev(self.bundlebase(rev2))
            if revb == rev1:
                return self._chunk(rev2)
        elif not self.inbundle(rev1) and not self.inbundle(rev2):
            return revlog.revlog.revdiff(self, rev1, rev2)

        return mdiff.textdiff(self.revision(self.node(rev1)),
                         self.revision(self.node(rev2)))
Example #10
0
    def revdiff(self, rev1, rev2):
        """return or calculate a delta between two revisions"""
        if self.inbundle(rev1) and self.inbundle(rev2):
            # hot path for bundle
            revb = self.rev(self.bundlebase(rev2))
            if revb == rev1:
                return self._chunk(rev2)
        elif not self.inbundle(rev1) and not self.inbundle(rev2):
            return revlog.revlog.revdiff(self, rev1, rev2)

        return mdiff.textdiff(self.revision(self.node(rev1)),
                              self.revision(self.node(rev2)))
Example #11
0
 def builddelta(rev):
     # can we use the cached delta?
     if cachedelta and cachedelta[0] == rev:
         delta = cachedelta[1]
     else:
         t = buildtext()
         ptext = self.revision(self.node(rev))
         delta = mdiff.textdiff(ptext, t)
     data = compress(delta)
     l = len(data[1]) + len(data[0])
     base = self.base(rev)
     dist = l + offset - self.start(base)
     return dist, l, data, base
 def builddelta(rev):
     # can we use the cached delta?
     if cachedelta and cachedelta[0] == rev:
         delta = cachedelta[1]
     else:
         t = buildtext()
         ptext = self.revision(self.node(rev))
         delta = mdiff.textdiff(ptext, t)
     data = compress(delta)
     l = len(data[1]) + len(data[0])
     base = self.base(rev)
     dist = l + offset - self.start(base)
     return dist, l, data, base
Example #13
0
    def _addrevision(self, text, transaction, link, p1, p2, d, ifh, dfh):
        node = hash(text, p1, p2)
        if node in self.nodemap:
            return node

        curr = len(self)
        prev = curr - 1
        base = self.base(prev)
        offset = self.end(prev)

        if curr:
            if not d:
                ptext = self.revision(self.node(prev))
                d = mdiff.textdiff(ptext, text)
            data = compress(d)
            l = len(data[1]) + len(data[0])
            dist = l + offset - self.start(base)

        # full versions are inserted when the needed deltas
        # become comparable to the uncompressed text
        if not curr or dist > len(text) * 2:
            data = compress(text)
            l = len(data[1]) + len(data[0])
            base = curr

        e = (offset_type(offset, 0), l, len(text),
             base, link, self.rev(p1), self.rev(p2), node)
        self.index.insert(-1, e)
        self.nodemap[node] = curr

        entry = self._io.packentry(e, self.node, self.version, curr)
        if not self._inline:
            transaction.add(self.datafile, offset)
            transaction.add(self.indexfile, curr * len(entry))
            if data[0]:
                dfh.write(data[0])
            dfh.write(data[1])
            dfh.flush()
            ifh.write(entry)
        else:
            offset += curr * self._io.size
            transaction.add(self.indexfile, offset, curr)
            ifh.write(entry)
            ifh.write(data[0])
            ifh.write(data[1])
            self.checkinlinesize(transaction, ifh)

        if type(text) == str: # only accept immutable objects
            self._cache = (node, curr, text)
        return node
Example #14
0
    def _addrevision(self, text, transaction, link, p1, p2, d, ifh, dfh):
        node = hash(text, p1, p2)
        if node in self.nodemap:
            return node

        curr = len(self)
        prev = curr - 1
        base = self.base(prev)
        offset = self.end(prev)

        if curr:
            if not d:
                ptext = self.revision(self.node(prev))
                d = mdiff.textdiff(ptext, text)
            data = compress(d)
            l = len(data[1]) + len(data[0])
            dist = l + offset - self.start(base)

        # full versions are inserted when the needed deltas
        # become comparable to the uncompressed text
        if not curr or dist > len(text) * 2:
            data = compress(text)
            l = len(data[1]) + len(data[0])
            base = curr

        e = (offset_type(offset, 0), l, len(text), base, link, self.rev(p1),
             self.rev(p2), node)
        self.index.insert(-1, e)
        self.nodemap[node] = curr

        entry = self._io.packentry(e, self.node, self.version, curr)
        if not self._inline:
            transaction.add(self.datafile, offset)
            transaction.add(self.indexfile, curr * len(entry))
            if data[0]:
                dfh.write(data[0])
            dfh.write(data[1])
            dfh.flush()
            ifh.write(entry)
        else:
            offset += curr * self._io.size
            transaction.add(self.indexfile, offset, curr)
            ifh.write(entry)
            ifh.write(data[0])
            ifh.write(data[1])
            self.checkinlinesize(transaction, ifh)

        if type(text) == str:  # only accept immutable objects
            self._cache = (node, curr, text)
        return node
Example #15
0
 def builddelta(rev):
     # can we use the cached delta?
     if cachedelta and cachedelta[0] == rev:
         delta = cachedelta[1]
     else:
         t = buildtext()
         ptext = self.revision(self.node(rev))
         delta = mdiff.textdiff(ptext, t)
     data = compress(delta)
     l = len(data[1]) + len(data[0])
     if basecache[0] == rev:
         chainbase = basecache[1]
     else:
         chainbase = self.chainbase(rev)
     dist = l + offset - self.start(chainbase)
     if self._generaldelta:
         base = rev
     else:
         base = chainbase
     return dist, l, data, base, chainbase
Example #16
0
 def builddelta(rev):
     # can we use the cached delta?
     if cachedelta and cachedelta[0] == rev:
         delta = cachedelta[1]
     else:
         t = buildtext()
         ptext = self.revision(self.node(rev))
         delta = mdiff.textdiff(ptext, t)
     data = compress(delta)
     l = len(data[1]) + len(data[0])
     if basecache[0] == rev:
         chainbase = basecache[1]
     else:
         chainbase = self.chainbase(rev)
     dist = l + offset - self.start(chainbase)
     if self._generaldelta:
         base = rev
     else:
         base = chainbase
     return dist, l, data, base, chainbase