2022-10-22 12:03:21 +02:00
|
|
|
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:
|
2022-10-24 12:01:28 +02:00
|
|
|
if rev.broken:
|
|
|
|
continue
|
2022-10-24 20:21:53 +02:00
|
|
|
if prev and prev.files_hash == rev.files_hash:
|
2022-10-22 12:03:21 +02:00
|
|
|
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:
|
2022-10-24 20:21:53 +02:00
|
|
|
print(rev, rev.files_hash)
|
2022-10-22 12:03:21 +02:00
|
|
|
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):
|
2022-10-25 13:24:08 +02:00
|
|
|
# this happened after the fact - possibly a revert
|
|
|
|
if rev2.commit_time > rev.commit_time:
|
|
|
|
continue
|
2022-10-24 20:21:53 +02:00
|
|
|
if rev2.files_hash == rev.files_hash:
|
2022-10-26 22:18:16 +02:00
|
|
|
print(" ", rev2, rev2.files_hash)
|