Up

Module Patience_diff = Patience_diff

Signature

module Matching_block : sig .. end
Bram Cohen's comment from the original Python code (with syntax changed to OCaml):
val get_matching_blocks : transform:('a -> 'b) -> compare:('b -> 'b -> int) -> mine:'a array -> other:'a array -> Matching_block.t list
val matches : compare:('a -> 'a -> int) -> 'a array -> 'a array -> (int * int) list

matches a b returns a list of pairs (i,j) such that a.(i) = b.(j) and such that the list is strictly increasing in both its first and second coordinates. This is essentially a "unfolded" version of what get_matching_blocks returns. Instead of grouping the consecutive matching block using length this function would return all the pairs (mine_start * other_start).

val ratio : 'a array -> 'a array -> float
module Range : sig .. end
For handling diffs abstractly.
module Hunk : sig .. end
In diff terms, a hunk is a unit of consecutive ranges with some Same context before and after New, Old, and Replace ranges.
val get_hunks : transform:('a -> 'b) -> compare:('b -> 'b -> int) -> context:int -> mine:'a array -> other:'a array -> 'a Hunk.t list

get_hunks a b ~context ~compare will compare the arrays a and b using compare and produce a list of hunks. (The hunks will contain Same ranges of at most context elements.) context defaults to infinity (producing a singleton hunk list), compare defaults to polymorphic compare.

val print_ranges : string Hunk.t -> unit
val all_same : 'a Hunk.t list -> bool

get_status hunks returns `Same if each hunk in hunks has only Same ranges.

val unified : 'a Hunk.t list -> 'a Hunk.t list

unified hunks converts all Replace ranges in hunks to an Old range followed by a New range.

val old_only : 'a Hunk.t list -> 'a Hunk.t list

old_only hunks drops all New ranges from hunks and converts all Replace ranges to Old ranges.

val new_only : 'a Hunk.t list -> 'a Hunk.t list

new_only hunks drops all Old ranges from hunks and converts all Replace ranges to New ranges.

val ranges : 'a Hunk.t list -> 'a Range.t list

ranges hunks concatenates all the ranges of all hunks together *

type 'a segment =
| Same of 'a array
| Different of 'a array array
type 'a merged_array = 'a segment list
val merge : 'a array array -> 'a merged_array