diff options
| author | Loek Le Blansch <loek.le-blansch.pv@renesas.com> | 2026-01-19 14:31:10 +0100 |
|---|---|---|
| committer | Loek Le Blansch <loek.le-blansch.pv@renesas.com> | 2026-01-19 14:31:10 +0100 |
| commit | c5d635c2378e3629af957d2397933e00788c060f (patch) | |
| tree | da147403887a9b705d29992245014b8ae4b6deca | |
| parent | 6f50423eaae06421aa6e9bd1976491f29b1466e3 (diff) | |
| -rw-r--r-- | patchtree/diff.py | 15 | ||||
| -rw-r--r-- | patchtree/process.py | 14 | ||||
| -rw-r--r-- | patchtree/spec.py | 6 |
3 files changed, 33 insertions, 2 deletions
diff --git a/patchtree/diff.py b/patchtree/diff.py index f8444e7..42e9c76 100644 --- a/patchtree/diff.py +++ b/patchtree/diff.py @@ -59,6 +59,21 @@ class File: def __repr__(self): return f"{self.__class__.__name__}(mode={self.mode:06o}, content={repr(self.content)})" + def __eq__(self, other): + if not isinstance(other, File): + return False + if self.mode != other.mode: + return False + a = self.content or b"" + b = other.content or b"" + if isinstance(a, str): + a = bytes(a, "utf-8") + if isinstance(b, str): + b = bytes(b, "utf-8") + if a != b: + return False + return True + class Diff: """ diff --git a/patchtree/process.py b/patchtree/process.py index decc7d1..5d64470 100644 --- a/patchtree/process.py +++ b/patchtree/process.py @@ -189,12 +189,22 @@ class ExecProcess(Process): if isinstance(data["cmd"], str): self.cmd = split(data["cmd"]) elif isinstance(data["cmd"], list): - self.cmd = data["cmd"] - # TODO: check if each list item is actually a string + self.cmd = self.argv_expand(data["cmd"]) else: raise TypeError("invalid type of key `cmd'") del data["cmd"] + def argv_expand(self, args: list[Any]): + args_out = [] + for arg in args: + if isinstance(arg, ProcessInputSpec): + args_out.append(str(arg.as_tmp())) + continue + + # else, cast to string + args_out.append(str(arg)) + return args_out + def transform(self): assert len(self.cmd) > 0 diff --git a/patchtree/spec.py b/patchtree/spec.py index 6b6cc28..928a41b 100644 --- a/patchtree/spec.py +++ b/patchtree/spec.py @@ -8,6 +8,9 @@ from pathlib import Path class ProcessInputSpec: """Processor input specification (abstract base)""" + def as_tmp(self): + raise NotImplementedError + @dataclass class FileInputSpec(ProcessInputSpec): @@ -25,6 +28,9 @@ class TargetFileInputSpec(FileInputSpec): class PatchsetFileInputSpec(FileInputSpec): """Spec to use a file (referenced by name) in the patchset directory (concrete)""" + def as_tmp(self): + return self.path + @dataclass class DefaultInputSpec(ProcessInputSpec): |