From 310786bac1dff6004caf99755c865e8e68274fb6 Mon Sep 17 00:00:00 2001 From: Yu Ming Zhu Date: May 20 2019 21:04:20 +0000 Subject: check duplicated parent_id in changes --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 7c0f5fc..5a391f2 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -682,6 +682,8 @@ def _writeInheritanceData(tag_id, changes, clear=False): fields = ('parent_id', 'priority', 'maxdepth', 'intransitive', 'noconfig', 'pkg_filter') if isinstance(changes, dict): changes = [changes] + # duplicated parent_id should not be contained in changes + parent_ids = set() for link in changes: check_fields = fields if link.get('delete link'): @@ -689,6 +691,12 @@ def _writeInheritanceData(tag_id, changes, clear=False): for f in check_fields: if f not in link: raise koji.GenericError("No value for %s" % f) + parent_id = link['parent_id'] + if parent_id in parent_ids: + raise koji.GenericError("Changes should not contain duplicated" + " parent_id(%i)" % parent_id) + else: + parent_ids.add(parent_id) # read current data and index data = dict([[link['parent_id'], link] for link in readInheritanceData(tag_id)]) for link in changes: