Module Patience_diff

module Patience_diff: sig .. end
This is a port of Bram Cohen's patience diff algorithm, as found in the Bazaar 1.14.1 source code, available at http://bazaar-vcs.org.

This copyright notice was included:

# Copyright (C) 2005 Bram Cohen, Copyright (C) 2005, 2006 Canonical Ltd # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA


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 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.
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