Exemplo n.º 1
0
 def getChange(self, number, patchset, refresh=False):
     key = '%s,%s' % (number, patchset)
     change = None
     if key in self._change_cache:
         change = self._change_cache.get(key)
         if not refresh:
             return change
     if not change:
         change = Change(None)
         change.number = number
         change.patchset = patchset
     key = '%s,%s' % (change.number, change.patchset)
     self._change_cache[key] = change
     self.updateChange(change)
     return change
Exemplo n.º 2
0
 def getChange(self, number, patchset, refresh=False):
     key = '%s,%s' % (number, patchset)
     change = None
     if key in self._change_cache:
         change = self._change_cache.get(key)
         if not refresh:
             return change
     if not change:
         change = Change(None)
         change.number = number
         change.patchset = patchset
     key = '%s,%s' % (change.number, change.patchset)
     self._change_cache[key] = change
     self.updateChange(change)
     return change
Exemplo n.º 3
0
 def _getChange(self, number, patchset, refresh=False, history=None):
     key = '%s,%s' % (number, patchset)
     change = self.connection.getCachedChange(key)
     if change and not refresh:
         return change
     if not change:
         change = Change(None)
         change.number = number
         change.patchset = patchset
     key = '%s,%s' % (change.number, change.patchset)
     self.connection.updateChangeCache(key, change)
     try:
         self._updateChange(change, history)
     except Exception:
         self.connection.deleteCachedChange(key)
         raise
     return change
Exemplo n.º 4
0
 def _getChange(self, number, patchset, refresh=False, history=None):
     key = '%s,%s' % (number, patchset)
     change = self.connection.getCachedChange(key)
     if change and not refresh:
         return change
     if not change:
         change = Change(None)
         change.number = number
         change.patchset = patchset
     key = '%s,%s' % (change.number, change.patchset)
     self.connection.updateChangeCache(key, change)
     try:
         self._updateChange(change, history)
     except Exception:
         self.connection.deleteCachedChange(key)
         raise
     return change
Exemplo n.º 5
0
 def _getChange(self, number, patchset, refresh=False, history=None):
     key = '%s,%s' % (number, patchset)
     change = None
     if key in self._change_cache:
         change = self._change_cache.get(key)
         if not refresh:
             return change
     if not change:
         change = Change(None)
         change.number = number
         change.patchset = patchset
     key = '%s,%s' % (change.number, change.patchset)
     self._change_cache[key] = change
     try:
         self.updateChange(change, history)
     except Exception:
         del self._change_cache[key]
         raise
     return change
Exemplo n.º 6
0
    def getChange(self, number, patchset, changes=None):
        self.log.info("Getting information for %s,%s" % (number, patchset))
        if changes is None:
            changes = {}
        data = self.gerrit.query(number)
        project = self.sched.projects[data['project']]
        change = Change(project)
        change._data = data

        change.number = number
        change.patchset = patchset
        change.project = project
        change.branch = data['branch']
        change.url = data['url']
        max_ps = 0
        for ps in data['patchSets']:
            if ps['number'] == patchset:
                change.refspec = ps['ref']
            if int(ps['number']) > int(max_ps):
                max_ps = ps['number']
        if max_ps == patchset:
            change.is_current_patchset = True
        else:
            change.is_current_patchset = False

        change.is_merged = self._isMerged(change)
        if change.is_merged:
            # This change is merged, so we don't need to look any further
            # for dependencies.
            return change

        key = '%s,%s' % (number, patchset)
        changes[key] = change

        def cachedGetChange(num, ps):
            key = '%s,%s' % (num, ps)
            if key in changes:
                return changes.get(key)
            c = self.getChange(num, ps, changes)
            return c

        if 'dependsOn' in data:
            parts = data['dependsOn'][0]['ref'].split('/')
            dep_num, dep_ps = parts[3], parts[4]
            dep = cachedGetChange(dep_num, dep_ps)
            if not dep.is_merged:
                change.needs_change = dep

        if 'neededBy' in data:
            for needed in data['neededBy']:
                parts = needed['ref'].split('/')
                dep_num, dep_ps = parts[3], parts[4]
                dep = cachedGetChange(dep_num, dep_ps)
                if not dep.is_merged and dep.is_current_patchset:
                    change.needed_by_changes.append(dep)

        return change
Exemplo n.º 7
0
    def getChange(self, number, patchset, queue_name, changes=None):
        # TODO: queue_name is screwing up the data model, refactor
        # the queue context so it isn't necessary.
        self.log.info("Getting information for %s,%s" % (number, patchset))
        if changes is None:
            changes = {}
        data = self.gerrit.query(number)
        project = self.sched.projects[data['project']]
        change = Change(queue_name, project)
        change._data = data

        change.number = number
        change.patchset = patchset
        change.project = project
        change.branch = data['branch']
        change.url = data['url']
        max_ps = 0
        for ps in data['patchSets']:
            if ps['number'] == patchset:
                change.refspec = ps['ref']
            if int(ps['number']) > int(max_ps):
                max_ps = ps['number']
        if max_ps == patchset:
            change.is_current_patchset = True
        else:
            change.is_current_patchset = False

        manager = self.sched.queue_managers[queue_name]
        change.can_merge = self._canMerge(change,
                                          manager.getSubmitAllowNeeds())
        change.is_merged = self._isMerged(change)
        if change.is_merged:
            # This change is merged, so we don't need to look any further
            # for dependencies.
            return change

        key = '%s,%s' % (number, patchset)
        changes[key] = change

        def cachedGetChange(num, ps):
            key = '%s,%s' % (num, ps)
            if key in changes:
                return changes.get(key)
            c = self.getChange(num, ps, queue_name, changes)
            return c

        if 'dependsOn' in data:
            parts = data['dependsOn'][0]['ref'].split('/')
            dep_num, dep_ps = parts[3], parts[4]
            dep = cachedGetChange(dep_num, dep_ps)
            if not dep.is_merged:
                change.needs_change = dep

        if 'neededBy' in data:
            for needed in data['neededBy']:
                parts = needed['ref'].split('/')
                dep_num, dep_ps = parts[3], parts[4]
                dep = cachedGetChange(dep_num, dep_ps)
                if not dep.is_merged and dep.is_current_patchset:
                    change.needed_by_changes.append(dep)

        return change