From 9c379a26df176660efe669c9c99a7152704c0c30 Mon Sep 17 00:00:00 2001
From: Ansgar Burchardt <ansgar@debian.org>
Date: Wed, 26 Sep 2012 22:05:55 +0200
Subject: [PATCH] daklib/archive.py: allow source to be in enhanced suite

This allows binNMUs for which the source is in stable to be accepted
into proposed-updates.

A better fix would be to handle this in _install_to_suite which already
does the right thing when source_suites is None.
---
 daklib/archive.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/daklib/archive.py b/daklib/archive.py
index 6aeeac4b..7dcc1af0 100644
--- a/daklib/archive.py
+++ b/daklib/archive.py
@@ -1151,7 +1151,14 @@ class ArchiveUpload(object):
             if policy_queue is not None:
                 redirected_suite = policy_queue.suite
 
-            source_suites = self.session.query(Suite).filter(Suite.suite_id.in_([suite.suite_id, redirected_suite.suite_id])).subquery()
+            # source can be in the suite we install to or any suite we enhance
+            source_suite_ids = set([suite.suite_id, redirected_suite.suite_id])
+            for enhanced_suite_id, in self.session.query(VersionCheck.reference_id) \
+                    .filter(VersionCheck.suite_id.in_(source_suite_ids)) \
+                    .filter(VersionCheck.check == 'Enhances'):
+                source_suite_ids.add(enhanced_suite_id)
+
+            source_suites = self.session.query(Suite).filter(Suite.suite_id.in_(source_suite_ids)).subquery()
 
             source_component_func = lambda source: self._source_override(overridesuite, source).component
             binary_component_func = lambda binary: self._binary_component(overridesuite, binary)
-- 
2.39.5