<commit_before>class CompUnit::Repository::FileSystem   { ... }
class CompUnit::Repository::Installation { ... }
class CompUnit::Repository::AbsolutePath { ... }
class CompUnit::Repository::NQP { ... }
class CompUnit::Repository::Perl5 { ... }

class CompUnit::RepositoryRegistry {
    my $lock     = Lock.new;

    method repository-for-spec(Str $spec, CompUnit::Repository :$next-repo) {
        state %include-spec2cur;
        state $lock = Lock.new;

        my ($short-id,%options,$path) := parse-include-spec($spec);
        my $class = short-id2class($short-id);
        die "No class loaded for short-id '$short-id': $spec -> $path"
          if $class === Any;

        my $abspath = $class.?absolutify($path) // $path;
        my $id      = "$short-id#$abspath";
        %options<next-repo> = $next-repo if $next-repo;
        $lock.protect( {
            %include-spec2cur{$id}:exists
              ?? %include-spec2cur{$id}
              !! (%include-spec2cur{$id} := $class.new(:prefix($abspath), |%options));
        } );
    }

    my %custom-lib;
    method setup-repositories() {
        my @INC;
        my %ENV := %*ENV; # only look up environment once

        # starting up for creating precomp
        if %ENV<RAKUDO_PRECOMP_WITH> -> \specs {
            @INC = specs.split(','); # assume well formed strings
        }

        # normal start up
        else {
            my $I := nqp::atkey(nqp::atkey(%*COMPILING, '%?OPTIONS'), 'I');
            if nqp::defined($I) {
                if nqp::islist($I) {
                    my Mu $iter := nqp::iterator($I);
                    while $iter {
                        @INC.append: parse-include-specS(nqp::shift($iter));
                    }
               }
                else {
                    @INC.append: parse-include-specS(nqp::p6box_s($I));
                }
            }

            if %ENV<RAKUDOLIB> -> $rakudolib {
                @INC.append: parse-include-specS($rakudolib);
            }
            if %ENV<PERL6LIB> -> $perl6lib {
                @INC.append: parse-include-specS($perl6lib);
            }

#?if jvm
            for nqp::hllize(nqp::jvmclasspaths()) -> $path {
                @INC.append: parse-include-specS($path);
            }
#?endif

            my $prefix := %*ENV<RAKUDO_PREFIX> // nqp::p6box_s(
              nqp::concat(nqp::atkey(nqp::backendconfig,'prefix'),'/share/perl6')
            );

            my $abspath := "$prefix/share/libraries.json";
            if IO::Path.new-from-absolute-path($abspath).e {
#            my $config = from-json( slurp $abspath );
#
#            for $config.list -> @group {
#                for @group>>.kv -> $class, $props {
#                    for $props.list -> $prop {
#                        if nqp::istype($prop,Associative) {
#                            for $prop.value.flat -> $path {
#                                @INC.push: parse-include-specS($path);
#                                %custom-lib{$prop.key} = $path;
#                            }
#                        }
#                        else {
#                            for $prop.flat -> $path {
#                                @INC.push: parse-include-specS($path);
#                            }
#                        }
#                    }
#                }
#            }
            }
            # There is no config file, so pick sane defaults.
            else {
                # XXX Various issues with this stuff on JVM
                my Mu $compiler := nqp::getcurhllsym('$COMPILER_CONFIG');  # TEMPORARY
                try {
                    if %ENV<HOME>
                      // (%ENV<HOMEDRIVE> // '') ~ (%ENV<HOMEPATH> // '') -> $home {
                        my $ver := nqp::p6box_s(nqp::atkey($compiler, 'version'));
                        my $path := "$home/.perl6/$ver";
                        @INC.append: (%custom-lib<home> = "inst#$path");
                    }
                }
                @INC.append:
                  (%custom-lib<site>   = "inst#$prefix/site"),
                  (%custom-lib<vendor> = "inst#$prefix/vendor"),
                  (%custom-lib<perl>   = "inst#$prefix");
            }
        }

        my CompUnit::Repository $next-repo := CompUnit::Repository::AbsolutePath.new(
            :next-repo(
                CompUnit::Repository::NQP.new(
                    :next-repo(CompUnit::Repository::Perl5.new)
                )
            )
        );
        my %repos;
        my $SPEC := $*SPEC;
        my &canon = -> $repo {<commit_msg>We no longer support config files<commit_after>class CompUnit::Repository::FileSystem   { ... }
class CompUnit::Repository::Installation { ... }
class CompUnit::Repository::AbsolutePath { ... }
class CompUnit::Repository::NQP { ... }
class CompUnit::Repository::Perl5 { ... }

class CompUnit::RepositoryRegistry {
    my $lock     = Lock.new;

    method repository-for-spec(Str $spec, CompUnit::Repository :$next-repo) {
        state %include-spec2cur;
        state $lock = Lock.new;

        my ($short-id,%options,$path) := parse-include-spec($spec);
        my $class = short-id2class($short-id);
        die "No class loaded for short-id '$short-id': $spec -> $path"
          if $class === Any;

        my $abspath = $class.?absolutify($path) // $path;
        my $id      = "$short-id#$abspath";
        %options<next-repo> = $next-repo if $next-repo;
        $lock.protect( {
            %include-spec2cur{$id}:exists
              ?? %include-spec2cur{$id}
              !! (%include-spec2cur{$id} := $class.new(:prefix($abspath), |%options));
        } );
    }

    my %custom-lib;
    method setup-repositories() {
        my @INC;
        my %ENV := %*ENV; # only look up environment once

        # starting up for creating precomp
        if %ENV<RAKUDO_PRECOMP_WITH> -> \specs {
            @INC = specs.split(','); # assume well formed strings
        }

        # normal start up
        else {
            my $I := nqp::atkey(nqp::atkey(%*COMPILING, '%?OPTIONS'), 'I');
            if nqp::defined($I) {
                if nqp::islist($I) {
                    my Mu $iter := nqp::iterator($I);
                    while $iter {
                        @INC.append: parse-include-specS(nqp::shift($iter));
                    }
               }
                else {
                    @INC.append: parse-include-specS(nqp::p6box_s($I));
                }
            }

            if %ENV<RAKUDOLIB> -> $rakudolib {
                @INC.append: parse-include-specS($rakudolib);
            }
            if %ENV<PERL6LIB> -> $perl6lib {
                @INC.append: parse-include-specS($perl6lib);
            }

#?if jvm
            for nqp::hllize(nqp::jvmclasspaths()) -> $path {
                @INC.append: parse-include-specS($path);
            }
#?endif

            my $prefix := %*ENV<RAKUDO_PREFIX> // nqp::p6box_s(
              nqp::concat(nqp::atkey(nqp::backendconfig,'prefix'),'/share/perl6')
            );

#            my $abspath := "$prefix/share/libraries.json";
#            if IO::Path.new-from-absolute-path($abspath).e {
#            my $config = from-json( slurp $abspath );
#
#            for $config.list -> @group {
#                for @group>>.kv -> $class, $props {
#                    for $props.list -> $prop {
#                        if nqp::istype($prop,Associative) {
#                            for $prop.value.flat -> $path {
#                                @INC.push: parse-include-specS($path);
#                                %custom-lib{$prop.key} = $path;
#                            }
#                        }
#                        else {
#                            for $prop.flat -> $path {
#                                @INC.push: parse-include-specS($path);
#                            }
#                        }
#                    }
#                }
#            }
#            }
            # There is no config file, so pick sane defaults.
#            else {
                # XXX Various issues with this stuff on JVM
                my Mu $compiler := nqp::getcurhllsym('$COMPILER_CONFIG');  # TEMPORARY
                try {
                    if %ENV<HOME>
                      // (%ENV<HOMEDRIVE> // '') ~ (%ENV<HOMEPATH> // '') -> $home {
                        my $ver := nqp::p6box_s(nqp::atkey($compiler, 'version'));
                        my $path := "$home/.perl6/$ver";
                        @INC.append: (%custom-lib<home> = "inst#$path");
                    }
                }
                @INC.append:
                  (%custom-lib<site>   = "inst#$prefix/site"),
                  (%custom-lib<vendor> = "inst#$prefix/vendor"),
                  (%custom-lib<perl>   = "inst#$prefix");
#            }
        }

        my CompUnit::Repository $next-repo := CompUnit::Repository::AbsolutePath.new(
            :next-repo(
                CompUnit::Repository::NQP.new(
                    :next-repo(CompUnit::Repository::Perl5.new)
                )
            )
        );
        my %repos;
        my $SPEC := $*SPEC;
        my &canon = -> $repo {
{'fraction_non_alphanumeric': 0.15388822049655473, 'fraction_numerical': 0.0032811987312698237, 'mean_word_length': 1.3290881304126336, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6121638', 'n_tokens_mistral': 2785, 'n_tokens_neox': 2633, 'n_words': 467}