forked from importers/git-importer
Fix files_hash calculcation and fake revisions
This commit is contained in:
parent
1c846e963c
commit
9bd6643e8a
@ -167,18 +167,6 @@ class Importer:
|
|||||||
(rev.dbid, linked_rev.dbid),
|
(rev.dbid, linked_rev.dbid),
|
||||||
)
|
)
|
||||||
|
|
||||||
def calculate_file_hashes(self, db):
|
|
||||||
with db.cursor() as cur:
|
|
||||||
cur.execute(
|
|
||||||
"SELECT * from revisions where files_hash IS NULL AND broken is FALSE"
|
|
||||||
)
|
|
||||||
for row in cur.fetchall():
|
|
||||||
rev = DBRevision(row)
|
|
||||||
md5 = rev.calculate_files_hash(db)
|
|
||||||
cur.execute(
|
|
||||||
"UPDATE revisions SET files_hash=%s WHERE id=%s", (md5, rev.dbid)
|
|
||||||
)
|
|
||||||
|
|
||||||
def fetch_all_linked_packages(self, db, project, package):
|
def fetch_all_linked_packages(self, db, project, package):
|
||||||
with db.cursor() as cur:
|
with db.cursor() as cur:
|
||||||
cur.execute(
|
cur.execute(
|
||||||
@ -193,12 +181,10 @@ class Importer:
|
|||||||
def find_fake_revisions(self, db):
|
def find_fake_revisions(self, db):
|
||||||
with db.cursor() as cur:
|
with db.cursor() as cur:
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"""SELECT * from revisions WHERE
|
"SELECT * from revisions WHERE id in (SELECT revision_id from linked_revs WHERE considered=FALSE)"
|
||||||
id in (SELECT revision_id from linked_revs WHERE considered=FALSE) AND
|
|
||||||
id not in (SELECT revision_id FROM fake_revs) ORDER by project,package,rev"""
|
|
||||||
)
|
)
|
||||||
for row in cur.fetchall():
|
for row in cur.fetchall():
|
||||||
DBRevision(row)
|
self._find_fake_revision(db, DBRevision(row))
|
||||||
|
|
||||||
def _find_fake_revision(self, db, rev):
|
def _find_fake_revision(self, db, rev):
|
||||||
prev = rev.previous_commit(db)
|
prev = rev.previous_commit(db)
|
||||||
@ -211,7 +197,7 @@ class Importer:
|
|||||||
return
|
return
|
||||||
with db.cursor() as cur:
|
with db.cursor() as cur:
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"""SELECT * from revisions where id in
|
"""SELECT * FROM revisions WHERE id IN
|
||||||
(SELECT revision_id from linked_revs WHERE linked_id=%s)
|
(SELECT revision_id from linked_revs WHERE linked_id=%s)
|
||||||
AND commit_time <= %s ORDER BY commit_time""",
|
AND commit_time <= %s ORDER BY commit_time""",
|
||||||
(prev.dbid, rev.commit_time),
|
(prev.dbid, rev.commit_time),
|
||||||
@ -305,13 +291,18 @@ class Importer:
|
|||||||
)
|
)
|
||||||
if list:
|
if list:
|
||||||
rev.import_dir_list(db, list)
|
rev.import_dir_list(db, list)
|
||||||
|
md5 = rev.calculate_files_hash(db)
|
||||||
|
with db.cursor() as cur:
|
||||||
|
cur.execute(
|
||||||
|
"UPDATE revisions SET files_hash=%s WHERE id=%s",
|
||||||
|
(md5, rev.dbid),
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
rev.set_broken(db)
|
rev.set_broken(db)
|
||||||
|
|
||||||
for number in DBRevision.requests_to_fetch(db, project, self.package):
|
for number in DBRevision.requests_to_fetch(db, project, self.package):
|
||||||
self.obs.request(number).import_into_db(db)
|
self.obs.request(number).import_into_db(db)
|
||||||
|
|
||||||
self.calculate_file_hashes(db)
|
|
||||||
db.conn.commit()
|
db.conn.commit()
|
||||||
TreeBuilder(db).build(self.package)
|
TreeBuilder(db).build(self.package)
|
||||||
|
|
||||||
|
@ -38,4 +38,4 @@ class TreeBuilder:
|
|||||||
if rev2.commit_time > rev.commit_time:
|
if rev2.commit_time > rev.commit_time:
|
||||||
continue
|
continue
|
||||||
if rev2.files_hash == rev.files_hash:
|
if rev2.files_hash == rev.files_hash:
|
||||||
print(" ", rev2)
|
print(" ", rev2, rev2.files_hash)
|
||||||
|
Loading…
Reference in New Issue
Block a user