The unpac monorepo manager self-hosting as a monorepo using unpac

Fpath.relativize: improve docs and change some suprising results.

Close #20.

+35 -7
+4
vendor/opam/fpath/CHANGES.md
··· 1 + 2 + - `Fpath.relativize` improve docs and change some correct but 3 + surpising results. Thanks to Martin Jambon for the report (#20). 4 + 1 5 v0.7.3 2020-09-08 Zagreb 2 6 ------------------------ 3 7
+5 -1
vendor/opam/fpath/src/fpath.ml
··· 484 484 (* Roots and relativization *) 485 485 486 486 let _relativize ~root p = 487 + if String.equal root p 488 + then Some (segs_to_path (if is_dir_path p then ["."; ""] else ["."])) else 487 489 let root = (* root is always interpreted as a directory *) 488 490 let root = normalize root in 489 491 if root.[String.length root - 1] = dir_sep_char then root else ··· 544 546 545 547 let is_rooted ~root p = match relativize ~root p with 546 548 | None -> false 547 - | Some r -> not (String.equal dotdot r || String.is_prefix ~affix:dotdot_dir r) 549 + | Some r -> 550 + not (String.equal dotdot r || String.is_prefix ~affix:dotdot_dir r || 551 + (String.equal root p && not (is_dir_path p))) 548 552 549 553 (* Predicates and comparison *) 550 554
+15 -6
vendor/opam/fpath/src/fpath.mli
··· 263 263 (** {1:rootrel Roots and relativization} *) 264 264 265 265 val relativize : root:t -> t -> t option 266 - (** [relativize ~root p] is: 266 + (** [relativize ~root p] tries to express path [p] relative to the directory 267 + [root]: 267 268 {ul 268 - {- [Some q] if there exists a {{!is_relative}relative} path [q] such 269 + {- [Some q] if there exists a {{!is_rel}relative} path [q] such 269 270 that [root // q] and [p] represent the same paths, 270 271 {{!is_dir_path}directoryness} included. They may however differ 271 272 syntactically when converted to a string. Note that [q] is 272 273 {{!normalize}normalized}.} 273 - {- [None] otherwise.}} 274 - 274 + {- [None] otherwise. This notably happens if [p] is absolute 275 + and [root] relative or if [root] is relative and [p] is absolute. 276 + In both cases it's not possible to know how to get from [p] from 277 + [root].}} 275 278 {{!ex_relativize}Examples}. *) 276 279 277 280 val is_rooted : root:t -> t -> bool ··· 855 858 856 859 {2:ex_relativize {!relativize}} 857 860 {ul 861 + {- [relativize ~root:(v "/a/b") (v "/a/b")] is [Some (v ".")]} 862 + {- [relativize ~root:(v "/a/b") (v "/a/b/")] is [Some (v "./")]} 863 + {- [relativize ~root:(v "/a/b/") (v "/a/b/")] is [Some (v "./")]} 864 + {- [relativize ~root:(v "/a/b/") (v "/a/b")] is [Some (v "../b")]} 865 + {- [relativize ~root:(v "a/b") (v "a/b")] is [Some (v ".")]} 866 + {- [relativize ~root:(v "a/b/") (v "a/b/")] is [Some (v "./")]} 867 + {- [relativize ~root:(v "a/b") (v "a/b/")] is [Some (v "./")]} 868 + {- [relativize ~root:(v "a/b/") (v "a/b")] is [Some (v "../b")]} 858 869 {- [relativize ~root:(v "/a/b") (v "c")] is [None]} 859 870 {- [relativize ~root:(v "/a/b") (v "/c")] is [Some (v "../../c")]} 860 871 {- [relativize ~root:(v "/a/b") (v "/c/")] is [Some (v "../../c/")]} ··· 862 873 {- [relativize ~root:(v "/a/b") (v "/c/")] is [Some (v "../../c/")]} 863 874 {- [relativize ~root:(v "/a/b") (v "/a/b/c")] is [Some (v "c")]} 864 875 {- [relativize ~root:(v "/a/b") (v "/a/b/c/")] is [Some (v "c/")]} 865 - {- [relativize ~root:(v "/a/b") (v "/a/b")] is [Some (v "../b")]} 866 - {- [relativize ~root:(v "/a/b") (v "/a/b/")] is [Some (v ".")]} 867 876 {- [relativize ~root:(v "a/b") (v "/c")] is [None].} 868 877 {- [relativize ~root:(v "a/b") (v "c")] is [Some (v "../../c")]} 869 878 {- [relativize ~root:(v "a/b") (v "c/")] is [Some (v "../../c/")]}
+11
vendor/opam/fpath/test/test_fpath.ml
··· 693 693 | None -> eq_opt None result ~__POS__ 694 694 | Some rel as r -> 695 695 eq_opt r result ~__POS__; 696 + let p = if Fpath.is_current_dir rel then Fpath.to_dir_path p else p in 696 697 eq (Fpath.normalize (Fpath.append root rel)) (Fpath.normalize p) 697 698 ~__POS__; 698 699 in 700 + relativize (v "/a/b") (v "/a/b") (Some (v ".")) ~__POS__; 701 + relativize (v "/a/b") (v "/a/b/") (Some (v "./")) ~__POS__; 702 + relativize (v "/a/b/") (v "/a/b/") (Some (v "./")) ~__POS__; 703 + relativize (v "/a/b/") (v "/a/b") (Some (v "../b")) ~__POS__; 704 + relativize (v "a/b") (v "a/b") (Some (v ".")) ~__POS__; 705 + relativize (v "a/b") (v "a/b/") (Some (v "./")) ~__POS__; 706 + relativize (v "a/b/") (v "a/b/") (Some (v "./")) ~__POS__; 707 + relativize (v "a/b/") (v "a/b") (Some (v "../b")) ~__POS__; 708 + relativize (v "a") (v "a") (Some (v ".")) ~__POS__; 709 + relativize (v "a/") (v "a/") (Some (v "./")) ~__POS__; 699 710 relativize (v "/a/") (v "/a") (Some (v "../a")) ~__POS__; 700 711 relativize (v "/a/") (v "/a/") (Some (v "./")) ~__POS__; 701 712 relativize (v "/a/") (v "/") (Some (v "../")) ~__POS__;