aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek.le-blansch.pv@renesas.com>2025-12-11 15:40:09 +0100
committerLoek Le Blansch <loek.le-blansch.pv@renesas.com>2025-12-11 15:40:09 +0100
commit47e993c6b8573b6a13ddcb69a7a0b5776fefeec1 (patch)
treef17d9795ae2e65ae9bcd3aaaea93eee2b7f866e7
parent7546a780f981c438fd531abe9e4387a42ee488ee (diff)
fix in-place editingdev
-rw-r--r--patchtree/cli.py11
-rw-r--r--patchtree/context.py9
2 files changed, 12 insertions, 8 deletions
diff --git a/patchtree/cli.py b/patchtree/cli.py
index f127d1c..83b955d 100644
--- a/patchtree/cli.py
+++ b/patchtree/cli.py
@@ -132,14 +132,11 @@ def main():
context = parse_arguments(config)
- patch = context.make_patch()
-
- if not context.in_place:
- context.output.write(patch)
- context.output.flush()
- context.output.close()
+ if context.in_place:
+ context.apply(True)
+ context.apply(False)
else:
- raise NotImplementedError("TODO")
+ context.write()
return 0
diff --git a/patchtree/context.py b/patchtree/context.py
index 65f9568..801923f 100644
--- a/patchtree/context.py
+++ b/patchtree/context.py
@@ -431,7 +431,7 @@ class Context:
raise Exception("cannot edit zip in-place!")
return ZipFS(target)
- raise Exception("cannot read `{target}'")
+ raise Exception(f"cannot read `{target}'")
def _get_output(self, options: Namespace) -> IO:
"""
@@ -440,6 +440,8 @@ class Context:
:returns: Output stream.
"""
if options.in_place:
+ if options.out is not None:
+ self.log.warning("--out is ignored when using --in-place")
return TextIO()
if options.out is not None:
@@ -496,3 +498,8 @@ class Context:
cmd.append(str(cache.absolute()))
run(cmd, cwd=str(location.absolute()))
+
+ def write(self) -> None:
+ patch = self.make_patch()
+ self.output.write(patch)
+ self.output.close()