Don't enqueue changes that are already in the queue.

Change-Id: I6be35d708fc13b5156270f2003d17a4afa856e4f
This commit is contained in:
James E. Blair 2012-07-16 14:23:52 -07:00
parent 6173fb3949
commit 0dc8ba922d
2 changed files with 36 additions and 1 deletions

View File

@ -328,6 +328,19 @@ class Change(object):
def __repr__(self):
return '<Change 0x%x %s>' % (id(self), self._id())
def equals(self, other):
if self.number:
if (self.number == other.number and
self.patchset == other.patchset):
return True
return False
if self.ref:
if (self.ref == other.ref and
self.newrew == other.newrev):
return True
return False
return False
def _filterJobs(self, jobs):
return filter(lambda job: job.eventMatches(self.event), jobs)

View File

@ -397,7 +397,16 @@ class BaseQueueManager(object):
return True
return False
def isChangeAlreadyInQueue(self, change):
for c in self.getChangesInQueue():
if change.equals(c):
return True
return False
def addChange(self, change):
if self.isChangeAlreadyInQueue(change):
self.log.debug("Change %s is already in queue, ignoring" % change)
return
self.log.debug("Adding change %s" % change)
if self.start_action:
try:
@ -507,11 +516,15 @@ for change %s:" % (job, change))
self.updateBuildDescriptions(change.current_build_set)
return ret
def formatStatusHTML(self):
def getChangesInQueue(self):
changes = []
for build, change in self.building_jobs.items():
if change not in changes:
changes.append(change)
return changes
def formatStatusHTML(self):
changes = self.getChangesInQueue()
ret = ''
for change in changes:
ret += change.formatStatus(html=True)
@ -571,6 +584,9 @@ class DependentQueueManager(BaseQueueManager):
self.log.error("Unable to find change queue for project %s" % project)
def addChange(self, change):
if self.isChangeAlreadyInQueue(change):
self.log.debug("Change %s is already in queue, ignoring" % change)
return
self.log.debug("Adding change %s" % change)
change_queue = self.getQueue(change.project)
if change_queue:
@ -665,6 +681,12 @@ behind failed change %s" % (
possibly reporting" % (change.change_behind, change))
self.possiblyReportChange(change.change_behind)
def getChangesInQueue(self):
changes = []
for shared_queue in self.change_queues:
changes.extend(shared_queue.queue)
return changes
def formatStatusHTML(self):
ret = ''
ret += '\n'