123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252open!Coreopen!Importletdefault_context=16(* The following constants were all chosen empirically. *)(* Default cutoff for line-level semantic cleanup. Any match of [default_line_big_enough]
or more will not be deleted, even if it's surrounded by large inserts and deletes.
Raising this quantity can only decrease the number of matches, and lowering it
can only increase the number of matches. *)letdefault_line_big_enough=3(* Analogous to above, but for word-level refinement *)letdefault_word_big_enough=7(* Governs the behavior of [split_for_readability]. We will only split ranges around
matches of size greater than [too_short_to_split]. Note that this should always
be at least 1, otherwise we will split on a single `Newline token.
Raising this quantity will result in less ranges being split, and setting it to
infinity is the same as passing in [~interleave:false]. *)lettoo_short_to_split=2letwarn_if_no_trailing_newline_in_both_default=truetypet={output:Output.t;rules:Format.Rules.t;float_tolerance:Percent.toption;produce_unified_lines:bool;unrefined:bool;keep_ws:bool;split_long_lines:bool;interleave:bool;assume_text:bool;context:int;line_big_enough:int;word_big_enough:int;shallow:bool;quiet:bool;double_check:bool;mask_uniques:bool;prev_alt:stringoption;next_alt:stringoption;location_style:Format.Location_style.t;warn_if_no_trailing_newline_in_both:bool[@defaultwarn_if_no_trailing_newline_in_both_default][@sexp_drop_default.equal]}[@@derivingcompare,fields,sexp_of]letinvariantt=Invariant.invariant[%here]t[%sexp_of:t](fun()->letcheckffield=Invariant.check_fieldtffieldinFields.iter~output:(check(funoutput->ifOutput.implies_unrefinedoutputthen[%test_eq:bool]t.unrefinedtrue~message:"output implies unrefined"))~rules:ignore~float_tolerance:ignore~produce_unified_lines:ignore~unrefined:ignore~keep_ws:ignore~interleave:ignore~assume_text:ignore~split_long_lines:ignore~context:ignore~line_big_enough:(check(funline_big_enough->[%test_pred:int]Int.is_positiveline_big_enough~message:"line_big_enough must be positive"))~word_big_enough:(check(funword_big_enough->[%test_pred:int]Int.is_positiveword_big_enough~message:"word_big_enough must be positive"))~shallow:ignore~quiet:ignore~double_check:ignore~mask_uniques:ignore~prev_alt:ignore~next_alt:ignore~location_style:ignore~warn_if_no_trailing_newline_in_both:ignore);;letcreate_exn~output~rules~float_tolerance~produce_unified_lines~unrefined~keep_ws~split_long_lines~interleave~assume_text~context~line_big_enough~word_big_enough~shallow~quiet~double_check~mask_uniques~prev_alt~next_alt~location_style~warn_if_no_trailing_newline_in_both=lett={output;rules;float_tolerance;produce_unified_lines;unrefined;keep_ws;split_long_lines;interleave;assume_text;context;line_big_enough;word_big_enough;shallow;quiet;double_check;mask_uniques;prev_alt;next_alt;location_style;warn_if_no_trailing_newline_in_both}ininvariantt;t;;letoverride?output?rules?float_tolerance?produce_unified_lines?unrefined?keep_ws?split_long_lines?interleave?assume_text?context?line_big_enough?word_big_enough?shallow?quiet?double_check?mask_uniques?prev_alt?next_alt?location_style?warn_if_no_trailing_newline_in_botht=letoutput=Option.value~default:t.outputoutputinletunrefined=Option.value~default:t.unrefinedunrefined||Output.implies_unrefinedoutputinlett=letvaluevaluefield=Option.valuevalue~default:(Field.getfieldt)inFields.map~output:(constoutput)~rules:(valuerules)~float_tolerance:(valuefloat_tolerance)~produce_unified_lines:(valueproduce_unified_lines)~unrefined:(constunrefined)~keep_ws:(valuekeep_ws)~interleave:(valueinterleave)~assume_text:(valueassume_text)~split_long_lines:(valuesplit_long_lines)~context:(valuecontext)~line_big_enough:(valueline_big_enough)~word_big_enough:(valueword_big_enough)~shallow:(valueshallow)~quiet:(valuequiet)~double_check:(valuedouble_check)~mask_uniques:(valuemask_uniques)~prev_alt:(valueprev_alt)~next_alt:(valuenext_alt)~location_style:(valuelocation_style)~warn_if_no_trailing_newline_in_both:(valuewarn_if_no_trailing_newline_in_both)ininvariantt;t;;letdefault={output=Ansi;rules={line_same=Format.Rule.create[]~pre:(Format.Rule.Affix.create" |"~styles:[BgBright_black;FgBlack]);line_prev=Format.Rule.create[FgRed]~pre:(Format.Rule.Affix.create"-|"~styles:[BgRed;FgBlack]);line_next=Format.Rule.create[FgGreen]~pre:(Format.Rule.Affix.create"+|"~styles:[BgGreen;FgBlack]);line_unified=Format.Rule.create[]~pre:(Format.Rule.Affix.create"!|"~styles:[BgYellow;FgBlack]);word_same_prev=Format.Rule.create[Dim];word_same_next=Format.Rule.blank;word_same_unified=Format.Rule.blank;word_prev=Format.Rule.create[FgRed];word_next=Format.Rule.create[FgGreen];hunk=Format.Rule.create[Bold]~pre:(Format.Rule.Affix.create"@|"~styles:[BgBright_black;FgBlack])~suf:(Format.Rule.Affix.create" ============================================================");header_prev=Format.Rule.create[Bold]~pre:(Format.Rule.Affix.create"------ "~styles:[FgRed]);header_next=Format.Rule.create[Bold]~pre:(Format.Rule.Affix.create"++++++ "~styles:[FgGreen])};float_tolerance=None;produce_unified_lines=true;unrefined=false;keep_ws=false;split_long_lines=false;interleave=true;assume_text=false;context=default_context;line_big_enough=default_line_big_enough;word_big_enough=default_word_big_enough;shallow=false;quiet=false;double_check=false;mask_uniques=false;prev_alt=None;next_alt=None;location_style=Diff;warn_if_no_trailing_newline_in_both=warn_if_no_trailing_newline_in_both_default};;