summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2019-11-01 14:02:08 -0700
committerGitHub <noreply@github.com>2019-11-01 14:02:08 -0700
commit2e029fc2e5fe58a1fb627e4856ab99a2abe17107 (patch)
treead6037f295245d5e0c35dcbdabcd09f2ebebd81c
parent24ec9f0ce39e97e4c74595208340bcfa3ffcdadd (diff)
downloadspack-2e029fc2e5fe58a1fb627e4856ab99a2abe17107.tar.gz
spack-2e029fc2e5fe58a1fb627e4856ab99a2abe17107.tar.bz2
spack-2e029fc2e5fe58a1fb627e4856ab99a2abe17107.tar.xz
spack-2e029fc2e5fe58a1fb627e4856ab99a2abe17107.zip
Bugfix: respect order of mirrors in mirrors.yaml (#13544)
Commands like "spack mirror list" were displaying mirrors in a different order than what was listed in the corresponding mirrors.yaml file. This restores commands to iterate over mirrors in the order that they appear in the config file.
-rw-r--r--lib/spack/spack/mirror.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/spack/spack/mirror.py b/lib/spack/spack/mirror.py
index 0c5e2a9cc2..21d34b579e 100644
--- a/lib/spack/spack/mirror.py
+++ b/lib/spack/spack/mirror.py
@@ -21,6 +21,8 @@ import six
import ruamel.yaml.error as yaml_error
+from ordereddict_backport import OrderedDict
+
try:
from collections.abc import Mapping
except ImportError:
@@ -166,7 +168,7 @@ class MirrorCollection(Mapping):
"""A mapping of mirror names to mirrors."""
def __init__(self, mirrors=None, scope=None):
- self._mirrors = dict(
+ self._mirrors = OrderedDict(
(name, Mirror.from_dict(mirror, name))
for name, mirror in (
mirrors.items() if mirrors is not None else
@@ -178,6 +180,7 @@ class MirrorCollection(Mapping):
def to_yaml(self, stream=None):
return syaml.dump(self.to_dict(True), stream)
+ # TODO: this isn't called anywhere
@staticmethod
def from_yaml(stream, name=None):
try: