7 # ./darcs-all [-q] [-s] [-i] [-r repo]
8 # [--nofib] [--testsuite] [--checked-out] cmd [darcs flags]
10 # Applies the darcs command "cmd" to each repository in the tree.
13 # ./darcs-all -r http://darcs.haskell.org/ghc get
14 # To get any repos which do not exist in the local tree
16 # ./darcs-all -r ~/ghc-validate push
17 # To push all your repos to the ~/ghc-validate tree
20 # To pull everything from the default repos
22 # ./darc-all push --dry-run
23 # To see what local patches you have relative to the main repos
25 # -q says to be quite, and -s to be silent.
27 # -i says to ignore darcs errors and move on to the next repository
29 # -r repo says to use repo as the location of package repositories
31 # --checked-out says that the remote repo is in checked-out layout, as
32 # opposed to the layout used for the main repo. By default a repo on
33 # the local filesystem is assumed to be checked-out, and repos accessed
34 # via HTTP or SSH are assumed to be in the main repo layout; use
35 # --checked-out to override the latter.
37 # --nofib, --testsuite also get the nofib and testsuite repos respectively
39 # The darcs get flag you are most likely to want is --complete. By
40 # default we pass darcs the --partial flag.
43 $| = 1; # autoflush stdout after each print, to avoid output after die
48 my $ignore_failure = 0;
49 my $want_remote_repo = 0;
50 my $checked_out_flag = 0;
54 # Figure out where to get the other repositories from.
57 my $repo = $defaultrepo || `cat $basedir/_darcs/prefs/defaultrepo`;
63 if ($repo =~ /^...*:/) {
65 # Above regex says "at least two chars before the :", to avoid
66 # catching Win32 drives ("C:\").
69 # --checked-out is needed if you want to use a checked-out repo
71 if ($checked_out_flag) {
72 $checked_out_tree = 1;
74 $checked_out_tree = 0;
77 # Don't drop the last part of the path if specified with -r, as
78 # it expects repos of the form:
80 # http://darcs.haskell.org
84 # http://darcs.haskell.org/ghc
87 $repo_base =~ s#/[^/]+/?$##;
90 elsif ($repo =~ /^\/|\.\.\/|.:(\/|\\)/) {
91 # Local filesystem, either absolute or relative path
92 # (assumes a checked-out tree):
94 $checked_out_tree = 1;
97 die "Couldn't work out repo";
100 return $repo_base, $checked_out_tree;
111 print "warning: @_\n";
116 message "== running darcs @_";
117 system ("darcs", @_) == 0
119 or die "darcs failed: $?";
129 my ($repo_base, $checked_out_tree) = getrepo();
131 open IN, "< packages" or die "Can't open packages file";
135 REPO: foreach (@repos) {
137 if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
139 $tag = defined($2) ? $2 : "";
142 if ($checked_out_tree) {
143 $path = "$repo_base/$localpath";
146 $path = "$repo_base/$remotepath";
149 if (-d "$localpath/_darcs") {
150 if ($want_remote_repo) {
151 darcs (@_, "--repodir", $localpath, $path);
153 darcs (@_, "--repodir", $localpath);
157 message "== Required repo $localpath is missing! Skipping";
160 message "== $localpath repo not present; skipping";
163 elsif (! /^(#.*)?$/) {
177 my ($repo_base, $checked_out_tree) = getrepo();
179 if (! grep /(?:--complete|--partial)/, @_) {
180 warning("adding --partial, to override use --complete");
181 $r_flags = [@_, "--partial"];
187 open IN, "< packages" or die "Can't open packages file";
193 if (/^([^ ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
195 $tag = defined($2) ? $2 : "";
198 if ($checked_out_tree) {
199 $path = "$repo_base/$localpath";
202 $path = "$repo_base/$remotepath";
205 if (($tag eq "") || defined($tags{$tag})) {
207 warning("$localpath already present; omitting");
210 darcs (@$r_flags, $path, $localpath);
214 elsif (! /^(#.*)?$/) {
221 if (! -d "compiler") {
222 die "error: darcs-all must be run from the top level of the ghc tree."
227 # We handle -q here as well as lower down as we need to skip over it
228 # if it comes before the darcs command
232 elsif ($arg eq "-s") {
235 elsif ($arg eq "-r") {
236 $defaultrepo = shift;
238 elsif ($arg eq "-i") {
241 # --nofib tells get to also grab the nofib repo.
242 # It has no effect on the other commands.
243 elsif ($arg eq "--nofib") {
246 # --testsuite tells get to also grab the testsuite repo.
247 # It has no effect on the other commands.
248 elsif ($arg eq "--testsuite") {
249 $tags{"testsuite"} = 1;
251 elsif ($arg eq "--checked-out") {
252 $checked_out_flag = 1;
256 if (grep /^-q$/, @_) {
264 die "What do you want to do?";
267 if ($command eq "get") {
271 if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew)$/) {
272 # Hack around whatsnew failing if there are no changes
275 if ($command =~ /^(pul|pus|sen|put)/) {
276 $want_remote_repo = 1;
283 message "== Checking for old bytestring repo";
284 if (-d "libraries/bytestring/_darcs") {
285 if ((system "darcs annotate --repodir libraries/bytestring --match 'hash 20080118173113-3fd76-d5b74c04372a297b585ebea4e16d524551ce5035' > /dev/null 2> /dev/null") == 0) {
287 ============================
290 You have an old bytestring repository in your GHC tree!
292 Please remove it (e.g. "rm -r libraries/bytestring"), and the new
293 version of bytestring will be used from a tarball instead.
294 ============================