From 10c7365115f1c20f1198cef23b94a0fc34473c00 Mon Sep 17 00:00:00 2001
From: Tomasz Bold <tomasz.bold@gmail.com>
Date: Thu, 25 Jul 2019 08:41:20 +0200
Subject: [PATCH] fixes to the appendToGlobals

---
 .../python/ComponentAccumulator.py                |  9 +++++----
 .../AthenaConfiguration/python/Deduplication.py   | 15 ++++++++++++---
 .../AthenaConfiguration/python/UnifyProperties.py |  1 +
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/Control/AthenaConfiguration/python/ComponentAccumulator.py b/Control/AthenaConfiguration/python/ComponentAccumulator.py
index c0e7328a661..c23124c0fcf 100644
--- a/Control/AthenaConfiguration/python/ComponentAccumulator.py
+++ b/Control/AthenaConfiguration/python/ComponentAccumulator.py
@@ -516,21 +516,22 @@ class ComponentAccumulator(object):
         Configurable.configurableRun3Behavior=0
         from AthenaCommon.AppMgr import ToolSvc, ServiceMgr, theApp
 
+        self._msg.debug("Merging services with global setup")
         for s in self._services:
-            deduplicate(s,ServiceMgr)
+            deduplicate(s, ServiceMgr.getChildren())
 
             if s.getJobOptName() in _servicesToCreate \
                     and s.getJobOptName() not in theApp.CreateSvc:
                 theApp.CreateSvc.append(s.getJobOptName())
 
-
-
         for t in self._publicTools:
             deduplicate(t,ToolSvc)
 
+        self._msg.debug("Merging conditions algorithms with global setup")
         condseq=AthSequencer ("AthCondSeq")
         for c in self._conditionsAlgs:
-            deduplicate(c,condseq)
+            deduplicate(c, condseq.getChildren() )
+
 
         for seqName, algoList in six.iteritems(flatSequencers( self._sequence )):
             seq=AthSequencer(seqName)
diff --git a/Control/AthenaConfiguration/python/Deduplication.py b/Control/AthenaConfiguration/python/Deduplication.py
index 4a123845789..94405311c95 100644
--- a/Control/AthenaConfiguration/python/Deduplication.py
+++ b/Control/AthenaConfiguration/python/Deduplication.py
@@ -9,7 +9,7 @@ from AthenaCommon.Configurable import ConfigurableAlgTool
 import collections
 from AthenaCommon.Logging import logging
 
-from AthenaConfiguration.UnifyProperties import unifyProperty 
+from AthenaConfiguration.UnifyProperties import unifyProperty
 
 _msg=logging.getLogger('ComponentAccumulator') #'Deduplication' would the better name but breaks tons of unit-test log comparison
 
@@ -19,6 +19,8 @@ class DeduplicationFailed(RuntimeError):
 
 def deduplicate(newComp,compList):
     #Check for duplicates:
+    _msg.debug("Deduplicating %s", newComp.getJobOptName())
+
     for idx,comp in enumerate(compList):
         if comp.getType()==newComp.getType() and comp.getFullName()==newComp.getFullName():
             #Found component of the same type and name
@@ -61,7 +63,7 @@ def deduplicateComponent(newComp,comp):
                 newprop=None
 
             # both are defined but with distinct type
-            if type(oldprop) != type(newprop):
+            if type(oldprop) != type(newprop) and oldprop != None and newprop != None:
                 raise DeduplicationFailed("Property  '%s' of component '%s' defined multiple times with conflicting types %s and %s" % \
                                           (prop,comp.getJobOptName(),type(oldprop),type(newprop)))
 
@@ -113,7 +115,13 @@ def deduplicateComponent(newComp,comp):
                         deduplicate(newTool,mergedHandleArray)
                     setattr(newComp,prop,mergedHandleArray)
                     pass
-                    
+
+                elif oldprop is None or oldprop == []:
+                    setattr(newComp,prop, newprop)
+
+                elif newprop is None or newprop == []:
+                    setattr(newComp,prop, oldprop)
+
                 elif isinstance(oldprop,collections.Sequence) or isinstance(oldprop,dict): #if properties are mergeable, do that!
                     #Try merging this property. Will raise on failure
                     mergeprop=unifyProperty(propid,oldprop,newprop)
@@ -122,6 +130,7 @@ def deduplicateComponent(newComp,comp):
                 elif isinstance(oldprop,PrivateToolHandle):
                     # This is because we get a PTH if the Property is set to None, and for some reason the equality doesn't work as expected here.
                     continue
+
                 else:
                     raise DeduplicationFailed("component '%s' defined multiple times with mismatching property %s" % \
                                                       (comp.getJobOptName(),str(prop)))
diff --git a/Control/AthenaConfiguration/python/UnifyProperties.py b/Control/AthenaConfiguration/python/UnifyProperties.py
index 3eb008254c0..bc5617ec562 100644
--- a/Control/AthenaConfiguration/python/UnifyProperties.py
+++ b/Control/AthenaConfiguration/python/UnifyProperties.py
@@ -62,6 +62,7 @@ _propsToUnify={"GeoModelSvc.DetectorTools":unifySet,
                "CondInputLoader.Load":unifySet,
                "IOVDbSvc.Folders":unifySet,
                "IOVDbSvc.FoldersToMetaData":unifySet,
+               "IOVDbSvc.overrideTags":unifySet,
                "EvtPersistencySvc.CnvServices":unifySet,
                "PoolSvc.ReadCatalog":unifySet,
                "ProxyProviderSvc.ProviderNames":unifySet,
-- 
GitLab