From 63cfa70f44ac9b08b214b30d80cd39b0295a1cd3 Mon Sep 17 00:00:00 2001 From: Mark Hymers Date: Sat, 31 Oct 2009 09:44:09 +0000 Subject: [PATCH] rename known_changes Signed-off-by: Mark Hymers --- dak/dakdb/update22.py | 3 +++ dak/import_known_changes.py | 4 ++-- daklib/changes.py | 2 +- daklib/dbconn.py | 22 +++++++++++----------- daklib/queue.py | 4 ++-- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/dak/dakdb/update22.py b/dak/dakdb/update22.py index 758430c1..e51e90ab 100755 --- a/dak/dakdb/update22.py +++ b/dak/dakdb/update22.py @@ -198,6 +198,9 @@ def do_update(self): print "Getting rid of old queue table" c.execute("""DROP TABLE queue""") + print "Moving known_changes table" + c.execute("""ALTER TABLE known_changes RENAME TO changes""") + print "Sorting out permissions" for t in ['build_queue', 'policy_queue', 'build_queue_files', diff --git a/dak/import_known_changes.py b/dak/import_known_changes.py index cdb1d3af..c8d5bf96 100755 --- a/dak/import_known_changes.py +++ b/dak/import_known_changes.py @@ -32,7 +32,7 @@ import sys import os import logging import threading -from daklib.dbconn import DBConn,get_knownchange +from daklib.dbconn import DBConn, get_dbchange from daklib.config import Config import apt_pkg from daklib.dak_exceptions import DBUpdateError, InvalidDscError, ChangesUnicodeError @@ -218,7 +218,7 @@ class ChangesGenerator(threading.Thread): continue count += 1 - if not get_knownchange(changesfile, self.session): + if not get_dbchange(changesfile, self.session): to_import = ChangesToImport(dirpath, changesfile, count) if self.die: return diff --git a/daklib/changes.py b/daklib/changes.py index 596b7461..4ee73fbc 100755 --- a/daklib/changes.py +++ b/daklib/changes.py @@ -179,7 +179,7 @@ class Changes(object): @session_wrapper def remove_known_changes(self, session=None): - session.delete(get_knownchange(self.changes_file, session)) + session.delete(get_dbchange(self.changes_file, session)) def mark_missing_fields(self): """add "missing" in fields which we will require for the known_changes table""" diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 5b30fce9..3c2b005e 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -1248,19 +1248,19 @@ __all__.append('KeyringACLMap') ################################################################################ -class KnownChange(object): +class DBChange(object): def __init__(self, *args, **kwargs): pass def __repr__(self): - return '' % self.changesname + return '' % self.changesname -__all__.append('KnownChange') +__all__.append('DBChange') @session_wrapper -def get_knownchange(filename, session=None): +def get_dbchange(filename, session=None): """ - returns knownchange object for given C{filename}. + returns DBChange object for given C{filename}. @type archive: string @param archive: the name of the arhive @@ -1273,14 +1273,14 @@ def get_knownchange(filename, session=None): @return: Archive object for the given name (None if not present) """ - q = session.query(KnownChange).filter_by(changesname=filename) + q = session.query(DBChange).filter_by(changesname=filename) try: return q.one() except NoResultFound: return None -__all__.append('get_knownchange') +__all__.append('get_dbchange') ################################################################################ @@ -2506,7 +2506,7 @@ class DBConn(Singleton): self.tbl_files = Table('files', self.db_meta, autoload=True) self.tbl_fingerprint = Table('fingerprint', self.db_meta, autoload=True) self.tbl_keyrings = Table('keyrings', self.db_meta, autoload=True) - self.tbl_known_changes = Table('known_changes', self.db_meta, autoload=True) + self.tbl_changes = Table('changes', self.db_meta, autoload=True) self.tbl_keyring_acl_map = Table('keyring_acl_map', self.db_meta, autoload=True) self.tbl_location = Table('location', self.db_meta, autoload=True) self.tbl_maintainer = Table('maintainer', self.db_meta, autoload=True) @@ -2611,8 +2611,8 @@ class DBConn(Singleton): properties = dict(keyring_name = self.tbl_keyrings.c.name, keyring_id = self.tbl_keyrings.c.id)) - mapper(KnownChange, self.tbl_known_changes, - properties = dict(known_change_id = self.tbl_known_changes.c.id, + mapper(DBChange, self.tbl_changes, + properties = dict(change_id = self.tbl_changes.c.id, poolfiles = relation(PoolFile, secondary=self.tbl_changes_pool_files, backref="changeslinks"), @@ -2626,7 +2626,7 @@ class DBConn(Singleton): mapper(ChangePendingSource, self.tbl_changes_pending_source, properties = dict(change_pending_source_id = self.tbl_changes_pending_source.c.id, - change = relation(KnownChange), + change = relation(DBChange), maintainer = relation(Maintainer, primaryjoin=(self.tbl_changes_pending_source.c.maintainer_id==self.tbl_maintainer.c.id)), changedby = relation(Maintainer, diff --git a/daklib/queue.py b/daklib/queue.py index effbb4e0..39dab347 100755 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -441,7 +441,7 @@ class Upload(object): # Check there isn't already a changes file of the same name in one # of the queue directories. base_filename = os.path.basename(filename) - if get_knownchange(base_filename): + if get_dbchange(base_filename): self.rejects.append("%s: a file with this name already exists." % (base_filename)) # Check the .changes is non-empty @@ -822,7 +822,7 @@ class Upload(object): session = DBConn().session() try: - changes = session.query(KnownChange).filter_by(changesname=base_filename).one() + changes = session.query(DBChange).filter_by(changesname=base_filename).one() if not changes.approved_for: self.rejects.append("%s file already known to dak" % base_filename) except NoResultFound, e: -- 2.39.5