module C0::Diff

Overview

C0DIFF parser and applier for atomic multi-file edits.

Format: [FS][GS][US][SUB][US]

TODO Consider a "replace-all within bounded scope" mode. Two unique sentinel anchors would define a region, and all occurrences within that region would be replaced. Candidate codes: SO/SI (0x0E/0x0F) — "Shift Out/In" to switch into replace-all mode: [GS][SO][SUB][SI] Open questions:

Defined in:

c0/diff.cr

Class Method Summary

Class Method Detail

def self.apply(diff_buf : Bytes, files : Hash(String, String)) : Hash(String, String) #

Apply a C0DIFF buffer to a hash of file contents. Returns the modified file contents. Raises on validation failure. All files are validated before any modifications (atomic semantics).


[View source]
def self.apply_files(diff_buf : Bytes, base_dir : String = ".") : Nil #

Apply a C0DIFF buffer to files on disk. Validates all files before writing any (atomic semantics).


[View source]
def self.build(& : DiffBuilder -> ) : Bytes #

Build a C0DIFF document.


[View source]
def self.parse(buf : Bytes) : Array(FileEdit) #

Parse a C0DIFF buffer into a list of file edits.


[View source]