42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
from lib.db_revision import DBRevision
|
|
from lib.request import Request
|
|
|
|
|
|
class TreeBuilder:
|
|
def __init__(self, db):
|
|
self.db = db
|
|
|
|
def filtered_revisions(self, project, package):
|
|
revisions = DBRevision.all_revisions(self.db, project, package)
|
|
revisions.sort()
|
|
ret = []
|
|
prev = None
|
|
for rev in revisions:
|
|
if rev.broken:
|
|
continue
|
|
if prev and prev.files_hash == rev.files_hash:
|
|
continue
|
|
ret.append(rev)
|
|
prev = rev
|
|
return ret
|
|
|
|
def build(self, package):
|
|
factory_revisions = self.filtered_revisions("openSUSE:Factory", package)
|
|
source_revisions = dict()
|
|
for rev in factory_revisions:
|
|
print(rev, rev.files_hash)
|
|
if rev.request_id:
|
|
req = Request.find(self.db, rev.request_id)
|
|
print(" ", req)
|
|
key = f"{req.source_project}/{req.source_package}"
|
|
if key not in source_revisions:
|
|
source_revisions[key] = self.filtered_revisions(
|
|
req.source_project, req.source_package
|
|
)
|
|
for rev2 in source_revisions.get(key):
|
|
# this happened after the fact - possibly a revert
|
|
if rev2.commit_time > rev.commit_time:
|
|
continue
|
|
if rev2.files_hash == rev.files_hash:
|
|
print(" ", rev2)
|