Ejemplo n.º 1
0
    def emitrevisions(
        self,
        nodes,
        nodesorder=None,
        revisiondata=False,
        assumehaveparentrevisions=False,
        deltamode=repository.CG_DELTAMODE_STD,
        sidedata_helpers=None,
    ):
        if nodesorder not in (b'nodes', b'storage', b'linear', None):
            raise error.ProgrammingError(
                b'unhandled value for nodesorder: %s' % nodesorder)

        nodes = [n for n in nodes if n != sha1nodeconstants.nullid]

        if not nodes:
            return

        # TODO perform in a single query.
        res = self._db.execute(
            'SELECT revnum, deltaid FROM fileindex '
            'WHERE pathid=? '
            '    AND node in (%s)' % (','.join(['?'] * len(nodes))),
            tuple([self._pathid] + nodes),
        )

        deltabases = {}

        for rev, deltaid in res:
            res = self._db.execute(
                'SELECT revnum from fileindex WHERE pathid=? AND deltaid=?',
                (self._pathid, deltaid),
            )
            deltabases[rev] = res.fetchone()[0]

        # TODO define revdifffn so we can use delta from storage.
        for delta in storageutil.emitrevisions(
                self,
                nodes,
                nodesorder,
                sqliterevisiondelta,
                deltaparentfn=deltabases.__getitem__,
                revisiondata=revisiondata,
                assumehaveparentrevisions=assumehaveparentrevisions,
                deltamode=deltamode,
                sidedata_helpers=sidedata_helpers,
        ):

            yield delta
Ejemplo n.º 2
0
    def emitrevisions(self,
                      nodes,
                      nodesorder=None,
                      revisiondata=False,
                      assumehaveparentrevisions=False,
                      deltaprevious=False):
        if nodesorder not in ('nodes', 'storage', 'linear', None):
            raise error.ProgrammingError('unhandled value for nodesorder: %s' %
                                         nodesorder)

        nodes = [n for n in nodes if n != nullid]

        if not nodes:
            return

        # TODO perform in a single query.
        res = self._db.execute(
            r'SELECT revnum, deltaid FROM fileindex '
            r'WHERE pathid=? '
            r'    AND node in (%s)' % (r','.join([r'?'] * len(nodes))),
            tuple([self._pathid] + nodes))

        deltabases = {}

        for rev, deltaid in res:
            res = self._db.execute(
                r'SELECT revnum from fileindex WHERE pathid=? AND deltaid=?',
                (self._pathid, deltaid))
            deltabases[rev] = res.fetchone()[0]

        # TODO define revdifffn so we can use delta from storage.
        for delta in storageutil.emitrevisions(
                self,
                nodes,
                nodesorder,
                sqliterevisiondelta,
                deltaparentfn=deltabases.__getitem__,
                revisiondata=revisiondata,
                assumehaveparentrevisions=assumehaveparentrevisions,
                deltaprevious=deltaprevious):

            yield delta