Skip to content
Snippets Groups Projects
Forked from Glasgow Haskell Compiler / GHC
51155 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
darcs-all 4.12 KiB
#!/usr/bin/perl -w

use strict;

my @top_dirs = ("nofib", "testsuite");

# Figure out where to get the other repositories from,
# based on where this GHC repo came from.
my $defaultrepo = `cat _darcs/prefs/defaultrepo`;
chomp $defaultrepo;
my $defaultrepo_base;
my $defaultrepo_lib;

if ($defaultrepo =~ /:/) {
    # HTTP or SSH
    $defaultrepo_base = $defaultrepo;
    $defaultrepo_base =~ s#/[^/]+/?$##;
    $defaultrepo_lib = "$defaultrepo_base/packages";
}
elsif ($defaultrepo =~ /^\//) {
    # Local filesystem, absolute path (assumes a checked-out tree):
    $defaultrepo_base = $defaultrepo;
    $defaultrepo_lib = "$defaultrepo/libraries";
}
elsif ($defaultrepo =~ /^..\//) {
    # Local filesystem, relative path (assumes a checked-out tree):
    $defaultrepo_base = $defaultrepo;
    $defaultrepo_lib = "$defaultrepo/libraries";
}
else {
    die "Couldn't work out defaultrepo";
}

my $verbose = 2;
my $ignore_failure = 0;

# --extra says we grab the extra libs with 'get'.  It has no effect on
# the other commands.
my $extra = 0;
# --nofib/--testsuite tell get to also grab the respective repos.
# They have no effect on the other commands.
my $nofib = 0;
my $testsuite = 0;

sub message {
    if ($verbose >= 2) {
        print "@_\n";
    }
}

sub warning {
    if ($verbose >= 1) {
        print "warning: @_\n";
    }
}

sub darcs {
    message "== running darcs @_";
    system ("darcs", @_) == 0
        or $ignore_failure
        or die "darcs failed: $?";
}

sub darcsall {
    darcs @_;
    for my $dir (@top_dirs) {
        if (-d $dir && -d "$dir/_darcs") {
            darcs (@_, "--repodir", $dir);
        }
        else {