Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add spack-python script to output diff in tree format #138

Merged
merged 14 commits into from
Feb 7, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
compare archs
  • Loading branch information
scheibelp committed Dec 17, 2024
commit f0e5ee47475142d3513109e934f9204c2ee82f1b
27 changes: 27 additions & 0 deletions lib/scripts/altdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,32 @@ def compare(self, other_spec):
self.newline_cb()
highlight(f"-> [{' '.join(extra)}]")

class ArchComparator:
def __init__(self, spec):
self.arch = spec.architecture

def _component_wise_diff(self, x, y, separator):
pairs = list(zip(x, y))
size = len(pairs)
for i, (xi, yi) in enumerate(pairs):
if xi == yi:
_write(xi)
else:
highlight(f"{xi}/{yi}")
if i < size - 1:
_write(separator)

def compare(self, other_spec):
this = [self.arch.platform, self.arch.os, str(self.arch.target)]
other_arch = other_spec.architecture
other = [other_arch.platform, other_arch.os, str(other_arch.target)]
other[2] = "foo"
if this == other:
_write(f" arch={self.arch}")
else:
_write(" arch=")
self._component_wise_diff(this, other, "-")

class NewlineWithDepthIndent:
def __init__(self):
self.depth = 0
Expand All @@ -88,6 +114,7 @@ def decompose(spec):
VersionComparator(spec),
CompilerComparator(spec),
VariantsComparator(spec),
ArchComparator(spec),
DepsComparator(spec, nl_cb),
]

Expand Down