Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Set up the whole chain of CompUnit::Repositorys
$*REPO is now the HEAD of the whole list of repositories.
  • Loading branch information
niner committed Oct 24, 2015
1 parent d4021f9 commit cf4233a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/core/CompUnit/Repository.pm
@@ -1,4 +1,6 @@
role CompUnit::Repository {
has CompUnit::Repository $.next-repo;

# Resolves a dependency specification to a concrete dependency. If the
# dependency was not already loaded, loads it. Returns a CompUnit
# object that represents the selected dependency. If there is no
Expand Down
7 changes: 5 additions & 2 deletions src/core/CompUnitRepo.pm
Expand Up @@ -33,7 +33,9 @@ class CompUnitRepo {
%language_module_loaders{$lang} := $loader;
}

method new(Str $spec) { INCLUDE-SPEC2CUR($spec) }
method new(Str $spec, CompUnit::Repository :$next-repo) {
INCLUDE-SPEC2CUR($spec, :$next-repo)
}

method files($file, :$name, :$auth, :$ver) {
for @*INC -> $spec {
Expand Down Expand Up @@ -154,7 +156,7 @@ sub SHORT-ID2CLASS(Str:D $short-id) {
SHORT-ID2CLASS('file') = 'CompUnitRepo::Local::File';
SHORT-ID2CLASS('inst') = 'CompUnitRepo::Local::Installation';

sub INCLUDE-SPEC2CUR(Str:D $spec) {
sub INCLUDE-SPEC2CUR(Str:D $spec, CompUnit::Repository :$next-repo) {
state %INCLUDE-SPEC2CUR;
state $lock = Lock.new;

Expand All @@ -165,6 +167,7 @@ sub INCLUDE-SPEC2CUR(Str:D $spec) {

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}
Expand Down
2 changes: 1 addition & 1 deletion src/core/CompUnitRepo/Local/Installation.pm
Expand Up @@ -2,7 +2,7 @@ class CompUnitRepo::Local::Installation does CompUnitRepo::Locally does CompUnit
has %!dists;
has $!cver = nqp::hllize(nqp::atkey(nqp::gethllsym('perl6', '$COMPILER_CONFIG'), 'version'));

submethod BUILD(:$!IO, :$!lock, :$!WHICH) {
submethod BUILD(:$!IO, :$!lock, :$!WHICH, :$next-repo) {
my $manifest := $!IO.child("MANIFEST");
my $abspath := $!IO.abspath;
%!dists{$abspath} = $manifest.e
Expand Down
4 changes: 2 additions & 2 deletions src/core/CompUnitRepo/Locally.pm
Expand Up @@ -5,12 +5,12 @@ role CompUnitRepo::Locally {

my %instances;

method new(CompUnitRepo::Locally: $dir) {
method new(CompUnitRepo::Locally: $dir, CompUnit::Repository :$next-repo) {
my $abspath := $*SPEC.rel2abs($dir);
my $IO := IO::Path.new-from-absolute-path($abspath);

%instances{$abspath} //=
self.bless(:$IO,:lock(Lock.new),:WHICH(self.^name ~ '|' ~ $abspath));
self.bless(:$IO, :lock(Lock.new), :WHICH(self.^name ~ '|' ~ $abspath), :$next-repo);
}

multi method Str(CompUnitRepo::Locally:D:) { $!IO.abspath }
Expand Down
4 changes: 3 additions & 1 deletion src/core/Process.pm
Expand Up @@ -37,7 +37,9 @@ multi sub INITIALIZE_DYNAMIC('$*TMPDIR') {
}

multi sub INITIALIZE_DYNAMIC('$*REPO') {
PROCESS::<$REPO> := CompUnitRepo.new(@*INC[0]);
my CompUnit::Repository $next-repo;
$next-repo := CompUnitRepo.new($_, :$next-repo) for @*INC.reverse;
PROCESS::<$REPO> := $next-repo;
}

multi sub INITIALIZE_DYNAMIC('$*HOME') {
Expand Down

0 comments on commit cf4233a

Please sign in to comment.