git-importer/lib/tree_builder.py

40 lines
1.4 KiB
Python
Raw Normal View History

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:
print(rev, rev.files_hash(self.db))
if rev.broken:
continue
2022-10-22 12:03:21 +02:00
if prev and prev.files_hash(self.db) == rev.files_hash(self.db):
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(self.db))
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):
if rev2.files_hash(self.db) == rev.files_hash(self.db):
print(" ", rev2)