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;
29 my $want_remote_repo = 0;
33 # Figure out where to get the other repositories from.
36 my $repo = $defaultrepo || `cat $basedir/_darcs/prefs/defaultrepo`;
42 if ($repo =~ /^...*:/) {
44 # Above regex says "at least two chars before the :", to avoid
45 # catching Win32 drives ("C:\").
47 $checked_out_tree = 0;
49 # Don't drop the last part of the path if specified with -r, as
50 # it expects repos of the form:
52 # http://darcs.haskell.org
56 # http://darcs.haskell.org/ghc
59 $repo_base =~ s#/[^/]+/?$##;
62 elsif ($repo =~ /^\/|\.\.\/|.:(\/|\\)/) {
63 # Local filesystem, either absolute or relative path
64 # (assumes a checked-out tree):
66 $checked_out_tree = 1;
69 die "Couldn't work out repo";
72 return $repo_base, $checked_out_tree;
83 print "warning: @_\n";
88 message "== running darcs @_";
89 system ("darcs", @_) == 0
91 or die "darcs failed: $?";
101 my ($repo_base, $checked_out_tree) = getrepo();
103 open IN, "< packages" or die "Can't open packages file";
107 REPO: foreach (@repos) {
109 if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
111 $tag = defined($2) ? $2 : "";
114 if ($checked_out_tree) {
115 $path = "$repo_base/$localpath";
118 $path = "$repo_base/$remotepath";
121 if (-d "$localpath/_darcs") {
122 if ($want_remote_repo) {
123 darcs (@_, "--repodir", $localpath, $path);
125 darcs (@_, "--repodir", $localpath);
129 message "== Required repo $localpath is missing! Skipping";
132 message "== $localpath repo not present; skipping";
135 elsif (! /^(#.*)?$/) {
149 my ($repo_base, $checked_out_tree) = getrepo();
151 if (! grep /(?:--complete|--partial)/, @_) {
152 warning("adding --partial, to override use --complete");
153 $r_flags = [@_, "--partial"];
159 open IN, "< packages" or die "Can't open packages file";
165 if (/^([^ ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
167 $tag = defined($2) ? $2 : "";
170 if ($checked_out_tree) {
171 $path = "$repo_base/$localpath";
174 $path = "$repo_base/$remotepath";
177 if (($tag eq "") || defined($tags{$tag})) {
179 warning("$localpath already present; omitting");
182 darcs (@$r_flags, $path, $localpath);
186 elsif (! /^(#.*)?$/) {
193 if (! -d "compiler") {
194 die "error: darcs-all must be run from the top level of the ghc tree."
199 # We handle -q here as well as lower down as we need to skip over it
200 # if it comes before the darcs command
204 elsif ($arg eq "-s") {
207 elsif ($arg eq "-r") {
208 $defaultrepo = shift;
210 elsif ($arg eq "-i") {
213 # --nofib tells get to also grab the nofib repo.
214 # It has no effect on the other commands.
215 elsif ($arg eq "--nofib") {
218 # --testsuite tells get to also grab the testsuite repo.
219 # It has no effect on the other commands.
220 elsif ($arg eq "--testsuite") {
221 $tags{"testsuite"} = 1;
225 if (grep /^-q$/, @_) {
233 die "What do you want to do?";
236 if ($command eq "get") {
240 if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew)$/) {
241 # Hack around whatsnew failing if there are no changes
244 if ($command =~ /^(pul|pus|sen|put)/) {
245 $want_remote_repo = 1;