diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py index 425fcec8eea744c8060b001a56d8a99e83727a5c..bbefd8d796a5adc66891079c682fb0a6121c86fa 100644 --- a/lib/spack/spack/config.py +++ b/lib/spack/spack/config.py @@ -944,6 +944,10 @@ def they_are(t): # track keys for marking key_marks = {} + # track this to ensure that source items come *before* dest in + # iteration order with OrderdDicts + dest_keys = [dk for dk in dest.keys() if dk not in source] + for sk, sv in iteritems(source): if _override(sk) or sk not in dest: # if sk ended with ::, or if it's new, completely override @@ -958,6 +962,12 @@ def they_are(t): # to copy mark information on source keys to dest. key_marks[sk] = sk + # ensure that dest keys come after source + for dk in dest_keys: + value = dest[dk] + del dest[dk] + dest[dk] = value + # ensure that keys are marked in the destination. The # key_marks dict ensures we can get the actual source key # objects from dest keys