예제 #1
0
    def _txn_getSourceStampNumbered(self, t, ssid):
        assert isinstance(ssid, (int, long))
        t.execute(
            self.quoteq("SELECT branch,revision,patchid,project,repository" " FROM sourcestamps WHERE id=?"), (ssid,)
        )
        r = t.fetchall()
        if not r:
            return None
        (branch_u, revision_u, patchid, project, repository) = r[0]
        branch = str_or_none(branch_u)
        revision = str_or_none(revision_u)

        patch = None
        if patchid is not None:
            t.execute(self.quoteq("SELECT patchlevel,patch_base64,subdir" " FROM patches WHERE id=?"), (patchid,))
            r = t.fetchall()
            assert len(r) == 1
            (patch_level, patch_text_base64, subdir_u) = r[0]
            patch_text = base64.b64decode(patch_text_base64)
            if subdir_u:
                patch = (patch_level, patch_text, str(subdir_u))
            else:
                patch = (patch_level, patch_text)

        t.execute(
            self.quoteq("SELECT changeid FROM sourcestamp_changes" " WHERE sourcestampid=?" " ORDER BY changeid ASC"),
            (ssid,),
        )
        r = t.fetchall()
        changes = None
        if r:
            changes = [self.getChangeNumberedNow(changeid, t) for (changeid,) in r]
        ss = SourceStamp(branch, revision, patch, changes, project=project, repository=repository)
        ss.ssid = ssid
        return ss
예제 #2
0
    def getSourceStampNumberedNow(self, ssid, t=None, old_res=None):
        assert isinstance(ssid, (int, long))
        ss = self._sourcestamp_cache.get(ssid)
        if ss:
            return ss
        
        assert isinstance(ssid, (int, long))
        sstamp_obj = rpc.RpcProxy('software_dev.commit')
        
        if not old_res:
            res = sstamp_obj.read(ssid)
        else:
            res = old_res
        if not res:
            return None

        branch = None # res['branch_url']
        revision = res.get('revno', False) or res.get('hash', '')

        patch = None
        #if patchid is not None:
        #    raise NotImplementedError

        changes = None
        
        changeid = ssid
        changes = [self.getChangeNumberedNow(changeid, t), ]
        ss = SourceStamp(branch, revision, patch, changes )
            # project=project, repository=repository)
        ss.ssid = ssid
        self._sourcestamp_cache.add(ssid, ss)
        return ss
예제 #3
0
    def getSourceStampNumberedNow(self, ssid, t=None, old_res=None):
        assert isinstance(ssid, (int, long))
        ss = self._sourcestamp_cache.get(ssid)
        if ss:
            return ss

        assert isinstance(ssid, (int, long))
        sstamp_obj = rpc.RpcProxy('software_dev.commit')

        if not old_res:
            res = sstamp_obj.read(ssid)
        else:
            res = old_res
        if not res:
            return None

        branch = None  # res['branch_url']
        revision = res.get('revno', False) or res.get('hash', '')

        patch = None
        #if patchid is not None:
        #    raise NotImplementedError

        changes = None

        changeid = ssid
        changes = [
            self.getChangeNumberedNow(changeid, t),
        ]
        ss = SourceStamp(branch, revision, patch, changes)
        # project=project, repository=repository)
        ss.ssid = ssid
        self._sourcestamp_cache.add(ssid, ss)
        return ss
예제 #4
0
    def _txn_getSourceStampNumbered(self, t, ssid):
        assert isinstance(ssid, (int, long))
        t.execute(
            self.quoteq("SELECT branch,revision,patchid,project,repository"
                        " FROM sourcestamps WHERE id=?"), (ssid, ))
        r = t.fetchall()
        if not r:
            return None
        (branch_u, revision_u, patchid, project, repository) = r[0]
        branch = str_or_none(branch_u)
        revision = str_or_none(revision_u)

        patch = None
        if patchid is not None:
            t.execute(
                self.quoteq("SELECT patchlevel,patch_base64,subdir"
                            " FROM patches WHERE id=?"), (patchid, ))
            r = t.fetchall()
            assert len(r) == 1
            (patch_level, patch_text_base64, subdir_u) = r[0]
            patch_text = base64.b64decode(patch_text_base64)
            if subdir_u:
                patch = (patch_level, patch_text, str(subdir_u))
            else:
                patch = (patch_level, patch_text)

        t.execute(
            self.quoteq("SELECT changeid FROM sourcestamp_changes"
                        " WHERE sourcestampid=?"
                        " ORDER BY changeid ASC"), (ssid, ))
        r = t.fetchall()
        changes = None
        if r:
            changes = [
                self.getChangeNumberedNow(changeid, t) for (changeid, ) in r
            ]
        ss = SourceStamp(branch,
                         revision,
                         patch,
                         changes,
                         project=project,
                         repository=repository)
        ss.ssid = ssid
        return ss