textutil::patch(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ textutil::patch ✨

okay bestie, so this is a page from the tcllib manual, section 3tcl, and it's about the textutil::patch thing. literally the whole vibe is: Application of uni-diff patches to directory trees. yes, like patch but it's a Tcl package and it does trees. we love that for us πŸ¦‹


🌸 SYNOPSIS 🌸

package require Tcl 8.5 9

package require textutil::patch ?0.2?

::textutil::patch::apply basedirectory striplevel patch reportcmd

{*}reportcmd apply filename

{*}reportcmd fail filename hunk expected seen

{*}reportcmd fail-already filename hunk

πŸ’… DESCRIPTION πŸ’…

so this package gives you literally one single command and what it does is apply a patch in unified format β€” the details on that format live over here: [https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html] β€” and it applies it to a directory tree. that's the whole thing. no cap. 🌈

✨ ::textutil::patch::apply basedirectory striplevel patch reportcmd

okay so this one applies the patch (heads up, it wants the text of the path, not the file) to the files sitting inside basedirectory, and it does it using the striplevel you handed it. and the result of the command? the empty string. that's it. iconic behaviour honestly.

about striplevel β€” it's the same energy as the -p option of the patch command. same thing, different font. πŸ’–

if the patch doesn't parse, it throws errors, and nothing happens to the files in basedirectory. like, not a single one. safe. periodt.

every activity that goes down while the patch is being applied β€” including the fact that it couldn't apply a hunk β€” gets reported through the command prefix reportcmd instead of screamed at you directly. files that have problems get left exactly how they were. but β€” and this is the important bit β€” that does not stop changes from landing on files with no problems, both before and after the problematic file(s). so like, it's not a full rollback situation, just so you know. 😭

so reportcmd gets called in 3 possible forms:

  • {*}reportcmd apply filename β€” the caller is starting operation on file fname, applying all the hunks it collected for that file. go off king πŸ‘‘
  • {*}reportcmd fail filename hunk expected seen β€” applying hunk number hunk of file filename failed. the command expected to find the text expected, and instead it saw seen. the audacity πŸ’€
  • {*}reportcmd fail-already filename hunk β€” applying hunk number hunk of file filename failed, because the command is pretty sure this hunk has already been applied to the file. it's giving dΓ©jΓ  vu 🫢

πŸŽ€ BUGS, IDEAS, FEEDBACK πŸŽ€

bestie, be real β€” this doc and the package it describes? yeah they're gonna have bugs and other problems. no notes, it's just how it is. please report them in the textutil category of the Tcllib Trackers: [http://core.tcl.tk/tcllib/reportlist]. and if you've got ideas for enhancements for the package and/or the docs, drop those there too, we're obsessed with feedback. ✨

if you're proposing code changes, please send unified diffs β€” i.e. the output of diff -u. that's the vibe. πŸ¦‹

and one more thing: attachments are strongly preferred over inlined patches. you can attach stuff by going to the Edit form of the ticket right after creating it, then hitting the left-most button in the secondary navigation bar. iykyk πŸ’…


πŸ”₯ KEYWORDS πŸ”₯

diff -ruN, diff, unified format, fossil, git, patch, unified format diff


πŸ‘‘ CATEGORY πŸ‘‘

Text processing


and that's the whole page, bestie!! this is from tcllib, version 0.2, dated back in the day, and it lives at textutil::patch(3tcl). slay, go apply some patches responsibly. mwah πŸŽ€πŸ’–

πŸ“¦ where this page comes from