forked from importers/git-importer
Create fake revisions for every commit in the base of a linked package
This is a rather complex operation, but whenever a package changes in Factory, the inherited package gets a shadow revision consisting of the 3-way merge. If this happens due to a request being accepted, this is actually in most cases also commited by 'buildservice-autocommit', so we're making sure this is always happening (and are actually duplicating revisions in cases that we filter out later as empty commits). To differenciate the fake revisions from the real revisions, I add a fraction part
This commit is contained in:
34
lib/db.py
34
lib/db.py
@@ -1,4 +1,7 @@
|
||||
import logging
|
||||
|
||||
import psycopg2
|
||||
from psycopg2.extras import LoggingConnection
|
||||
|
||||
from lib.config import config
|
||||
|
||||
@@ -14,7 +17,9 @@ class DB:
|
||||
# read the connection parameters
|
||||
params = config(section=self.config_section)
|
||||
# connect to the PostgreSQL server
|
||||
self.conn = psycopg2.connect(**params)
|
||||
self.conn = psycopg2.connect(connection_factory=LoggingConnection, **params)
|
||||
logger = logging.getLogger(__name__)
|
||||
self.conn.initialize(logger)
|
||||
|
||||
except (Exception, psycopg2.DatabaseError) as error:
|
||||
print(error)
|
||||
@@ -96,6 +101,7 @@ class DB:
|
||||
"UPDATE scheme SET version=4",
|
||||
)
|
||||
schemes[5] = (
|
||||
"""DROP TABLE IF EXISTS files""",
|
||||
"""
|
||||
CREATE TABLE files (
|
||||
id SERIAL PRIMARY KEY,
|
||||
@@ -109,6 +115,7 @@ class DB:
|
||||
"UPDATE scheme SET version=5",
|
||||
)
|
||||
schemes[6] = (
|
||||
"""DROP TABLE IF EXISTS requests""",
|
||||
"""
|
||||
CREATE TABLE requests (
|
||||
id SERIAL PRIMARY KEY,
|
||||
@@ -154,6 +161,7 @@ class DB:
|
||||
"UPDATE scheme SET version=12",
|
||||
)
|
||||
schemes[13] = (
|
||||
"""DROP TABLE IF EXISTS linked_revs""",
|
||||
"""
|
||||
CREATE TABLE users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
@@ -174,6 +182,30 @@ class DB:
|
||||
""",
|
||||
"UPDATE scheme SET version=14",
|
||||
)
|
||||
schemes[14] = (
|
||||
"ALTER TABLE revisions ALTER COLUMN rev TYPE real USING rev::real",
|
||||
"UPDATE scheme SET version=14",
|
||||
)
|
||||
schemes[15] = (
|
||||
"""DROP TABLE IF EXISTS fake_revs""",
|
||||
"""
|
||||
CREATE TABLE fake_revs (
|
||||
id SERIAL PRIMARY KEY,
|
||||
revision_id INTEGER NOT NULL,
|
||||
linked_id INTEGER NOT NULL
|
||||
)
|
||||
""",
|
||||
"create index revs_linked on fake_revs (revision_id,linked_id)",
|
||||
"UPDATE scheme SET version=15",
|
||||
)
|
||||
schemes[16] = (
|
||||
"ALTER TABLE revisions ADD COLUMN files_hash VARCHAR(40)",
|
||||
"UPDATE scheme SET version=16",
|
||||
)
|
||||
schemes[17] = (
|
||||
"ALTER TABLE linked_revs ADD COLUMN considered BOOLEAN DEFAULT FALSE",
|
||||
"UPDATE scheme SET version=17",
|
||||
)
|
||||
schema_version = self.schema_version()
|
||||
if (schema_version + 1) not in schemes:
|
||||
return
|
||||
|
Reference in New Issue
Block a user