7 # ./darcs-all [-q] [-s] [-i] [-r repo] [--nofib] [--testsuite] get [darcs get flags]
8 # This gets the GHC core repos, if they do not already exist.
9 # -q says to be quite, and -s to be silent.
10 # -i says to ignore darcs errors and move on to the next repository
11 # -r repo says to use repo as the location of package repositories
12 # --nofib, --testsuite also get the nofib and testsuite repos respectively
13 # The darcs get flag you are most likely to want is --complete. By
14 # default we pass darcs the --partial flag.
16 # ./darcs-all [-q] [-s] [-i] [-r repo] cmd [darcs cmd flags]
17 # This runs the darcs "cmd" command, with any flags you give, in all
18 # of the repos you have checked out. e.g.
20 # ./darcs-all -q send --dry-run
21 # -q says to be quite, and -s to be silent.
23 $| = 1; # autoflush stdout after each print, to avoid output after die
28 my $ignore_failure = 0;
32 # Figure out where to get the other repositories from.
35 my $repo = $defaultrepo || `cat $basedir/_darcs/prefs/defaultrepo`;
41 if ($repo =~ /^...*:/) {
43 # Above regex says "at least two chars before the :", to avoid
44 # catching Win32 drives ("C:\").
46 $checked_out_tree = 0;
48 # Don't drop the last part of the path if specified with -r, as
49 # it expects repos of the form:
51 # http://darcs.haskell.org
55 # http://darcs.haskell.org/ghc
58 $repo_base =~ s#/[^/]+/?$##;
61 elsif ($repo =~ /^\/|\.\.\/|.:(\/|\\)/) {
62 # Local filesystem, either absolute or relative path
63 # (assumes a checked-out tree):
65 $checked_out_tree = 1;
68 die "Couldn't work out repo";
71 return $repo_base, $checked_out_tree;
82 print "warning: @_\n";
87 message "== running darcs @_";
88 system ("darcs", @_) == 0
90 or die "darcs failed: $?";
100 my ($repo_base, $checked_out_tree) = getrepo();
102 open IN, "< packages" or die "Can't open packages file";
106 REPO: foreach (@repos) {
108 if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
110 $tag = defined($2) ? $2 : "";
113 if ($checked_out_tree) {
114 $path = "$repo_base/$localpath";
117 if ($remotepath =~ /^http:/) {
118 message "Ignoring $localpath; remote is http URL";
122 $path = "$repo_base/$remotepath";
126 if (-d "$localpath/_darcs") {
127 darcs (@_, "--repodir", $localpath, $path);
130 message "== Required repo $localpath is missing! Skipping";
133 message "== $localpath repo not present; skipping";
136 elsif (! /^(#.*)?$/) {
150 my ($repo_base, $checked_out_tree) = getrepo();
152 if (! grep /(?:--complete|--partial)/, @_) {
153 warning("adding --partial, to override use --complete");
154 $r_flags = [@_, "--partial"];
160 open IN, "< packages" or die "Can't open packages file";
166 if (/^([^ ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
168 $tag = defined($2) ? $2 : "";
171 if ($checked_out_tree) {
172 $path = "$repo_base/$localpath";
175 if ($remotepath =~ /^http:/) {
179 $path = "$repo_base/$remotepath";
183 if (($tag eq "") || defined($tags{$tag})) {
185 warning("$localpath already present; omitting");
188 darcs (@$r_flags, $path, $localpath);
192 elsif (! /^(#.*)?$/) {
199 if (! -d "compiler") {
200 die "error: darcs-all must be run from the top level of the ghc tree."
205 # We handle -q here as well as lower down as we need to skip over it
206 # if it comes before the darcs command
210 elsif ($arg eq "-s") {
213 elsif ($arg eq "-r") {
214 $defaultrepo = shift;
216 elsif ($arg eq "-i") {
219 # --nofib tells get to also grab the nofib repo.
220 # It has no effect on the other commands.
221 elsif ($arg eq "--nofib") {
224 # --testsuite tells get to also grab the testsuite repo.
225 # It has no effect on the other commands.
226 elsif ($arg eq "--testsuite") {
227 $tags{"testsuite"} = 1;
231 if (grep /^-q$/, @_) {
239 die "What do you want to do?";
242 if ($command eq "get") {
246 if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew)$/) {
247 # Hack around whatsnew failing if there are no changes