fitzzftw.patch.lines

        ---
config:
  height: 300px
  width: 300px

title: lines
---
classDiagram
  FileLine <|-- HunkLine
  PatchLine <|-- FileLine
  PatchLine <|-- HeadLine
  PatchLine <|-- HunkHeadLine
  TerminalColorMixin <|-- HeadLine
  TerminalColorMixin <|-- HunkHeadLine
  TerminalColorMixin <|-- HunkLine
    

Inheritage diagramm for lines

lines

This module provides the structural representation of individual lines within a patch file. It acts as a specialized parser that converts raw patch fragments into intelligent objects capable of self-validation and metadata extraction.

Core Line Types:

  • PatchLine: The base class for all lines, handling basic sanitization and trailing newline management.

  • HeadLine: Manages file headers (— and +++), extracting paths, timestamps, and identifying null-device targets.

  • HunkHeadLine: Parses the coordination metadata (@@ -l,s +l,s @@), providing structured access to line ranges.

  • FileLine & HunkLine: Represent actual content changes. They include advanced whitespace normalization logic (collapse, ignore-all) required for robust patch application across different formatting styles.

Key Features:

  • Integrated Styling: Most line classes inherit from base.TerminalColorMixin and define a _color_map, allowing them to print themselves with the correct semantic color (e.g., green for additions, red for deletions).

  • Whitespace Awareness: Objects can dynamically provide different representations of their content (normalized_ws_content, ignore_all_ws_content) to support flexible matching algorithms.

  • Protocol Compliance: By providing prefix, orig_line, and _color_map, these classes satisfy the LineLike protocol, enabling seamless integration with the framework’s diagnostic and output tools.

Classes

FileLine

Represents a single line read from a file or contained within a patch hunk.

HeadLine

Represents a file header line within a patch (starting with '--- ' or '+++ ').

HunkHeadLine

Represents a hunk header line within a patch (starting with '@@ ').

HunkLine

Represents a single content line within a hunk block of a unified diff.

PatchLine

Base class for structural patch lines.