]> err.no Git - dak/commitdiff
fix up existing changes file handling
authorMark Hymers <mhy@debian.org>
Sat, 31 Oct 2009 11:02:55 +0000 (11:02 +0000)
committerMark Hymers <mhy@debian.org>
Sat, 31 Oct 2009 11:02:55 +0000 (11:02 +0000)
Signed-off-by: Mark Hymers <mhy@debian.org>
dak/dakdb/update22.py
daklib/dbconn.py
daklib/queue.py

index e51e90ab436b0045525003d355ebd70b1225965f..7234555eda7ea8be18dd6785eccedfdd3929dbc5 100755 (executable)
@@ -166,6 +166,12 @@ def do_update(self):
                             sha1sum        TEXT NOT NULL,
                             sha256sum      TEXT NOT NULL )""")
 
+        c.execute("""CREATE TABLE changes_pending_files_map (
+                            file_id        INT4 NOT NULL REFERENCES changes_pending_files (id),
+                            change_id      INT4 NOT NULL REFERENCES known_changes (id),
+
+                            PRIMARY KEY (file_id, change_id))""")
+
         c.execute("""CREATE TABLE changes_pending_source (
                             id             SERIAL PRIMARY KEY,
                             change_id      INT4 NOT NULL REFERENCES known_changes (id),
index 3c2b005e03871ffc7d0541b0d98ebcccaef9cd5b..7add55ff61eafbdded2aa3c8887c75f9df474630 100755 (executable)
@@ -2499,6 +2499,7 @@ class DBConn(Singleton):
         self.tbl_content_file_paths = Table('content_file_paths', self.db_meta, autoload=True)
         self.tbl_changes_pending_binary = Table('changes_pending_binaries', self.db_meta, autoload=True)
         self.tbl_changes_pending_files = Table('changes_pending_files', self.db_meta, autoload=True)
+        self.tbl_changes_pending_files_map = Table('changes_pending_files_map', self.db_meta, autoload=True)
         self.tbl_changes_pending_source = Table('changes_pending_source', self.db_meta, autoload=True)
         self.tbl_changes_pending_source_files = Table('changes_pending_source_files', self.db_meta, autoload=True)
         self.tbl_changes_pool_files = Table('changes_pool_files', self.db_meta, autoload=True)
@@ -2616,7 +2617,13 @@ class DBConn(Singleton):
                                  poolfiles = relation(PoolFile,
                                                       secondary=self.tbl_changes_pool_files,
                                                       backref="changeslinks"),
-                                 files = relation(ChangePendingFile, backref="changesfile")))
+                                 files = relation(ChangePendingFile,
+                                                  secondary=self.tbl_changes_pending_files_map,
+                                                  backref="changesfile"),
+                                 in_queue_id = self.tbl_changes.c.in_queue,
+                                 in_queue = relation(PolicyQueue,
+                                                     primaryjoin=(self.tbl_changes.c.in_queue==self.tbl_policy_queue.c.id)),
+                                 approved_for_id = self.tbl_changes.c.approved_for))
 
         mapper(ChangePendingBinary, self.tbl_changes_pending_binary,
                properties = dict(change_pending_binary_id = self.tbl_changes_pending_binary.c.id))
index 39dab347da5133fcbeb3da741b41dfc2b59da75c..15a8395841b35e1134f2ae06ed40ebbe8639134b 100755 (executable)
@@ -438,12 +438,6 @@ class Upload(object):
         self.pkg.changes["chopversion"] = re_no_epoch.sub('', self.pkg.changes["version"])
         self.pkg.changes["chopversion2"] = re_no_revision.sub('', self.pkg.changes["chopversion"])
 
-        # 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_dbchange(base_filename):
-            self.rejects.append("%s: a file with this name already exists." % (base_filename))
-
         # Check the .changes is non-empty
         if not self.pkg.files:
             self.rejects.append("%s: nothing to do (Files field is empty)." % (base_filename))
@@ -822,8 +816,8 @@ class Upload(object):
         session = DBConn().session()
 
         try:
-            changes = session.query(DBChange).filter_by(changesname=base_filename).one()
-            if not changes.approved_for:
+            dbc = session.query(DBChange).filter_by(changesname=base_filename).one()
+            if dbc.in_queue is not None and dbc.in_queue.queue_name != 'unchecked':
                 self.rejects.append("%s file already known to dak" % base_filename)
         except NoResultFound, e:
             # not known, good