Make killThread# cmm primop use local stack allocation
[ghc-hetmet.git] / darcs-all
index 1e773c9..e8a1139 100644 (file)
--- a/darcs-all
+++ b/darcs-all
@@ -2,30 +2,44 @@
 
 use strict;
 
-my @top_dirs = ("nofib", "testsuite");
+# Usage:
+#
+# ./darcs-all [-q] [-s] [--nofib] [--testsuite] get [darcs get flags]
+#   This gets the GHC core repos, if they do not already exist.
+#   -q says to be quite, and -s to be silent.
+#   --nofib, --testsuite also get the nofib and testsuite repos respectively
+#   The darcs get flag you are most likely to want is --complete. By
+#   default we pass darcs the --partial flag.
+#
+# ./darcs-all [-q] [-s] cmd [darcs cmd flags]
+#   This runs the darcs "cmd" command, with any flags you give, in all
+#   of the repos you have checked out. e.g.
+#       ./darcs-all pull
+#       ./darcs-all -q send --dry-run
+#   -q says to be quite, and -s to be silent.
+
+$| = 1; # autoflush stdout after each print, to avoid output after die
 
 # 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;
+my $checked_out_tree;
 
-if ($defaultrepo =~ /:/) {
+if ($defaultrepo =~ /^...*:/) {
     # HTTP or SSH
+    # Above regex says "at least two chars before the :", to avoid
+    # catching Win32 drives ("C:\").
     $defaultrepo_base = $defaultrepo;
     $defaultrepo_base =~ s#/[^/]+/?$##;
-    $defaultrepo_lib = "$defaultrepo_base/packages";
+    $checked_out_tree = 0;
 }
-elsif ($defaultrepo =~ /^\//) {
-    # Local filesystem, absolute path (assumes a checked-out tree):
+elsif ($defaultrepo =~ /^\/|\.\.\/|.:(\/|\\)/) {
+    # Local filesystem, either absolute or relative 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";
+    $checked_out_tree = 1;
 }
 else {
     die "Couldn't work out defaultrepo";
@@ -34,13 +48,7 @@ else {
 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;
+my %tags;
 
 sub message {
     if ($verbose >= 2) {
@@ -62,41 +70,45 @@ sub darcs {
 }
 
 sub darcsall {
-    darcs @_;
-    for my $dir (@top_dirs) {
-        if (-d $dir && -d "$dir/_darcs") {
-            darcs (@_, "--repodir", $dir);
-        }
-        else {
-            message "== $dir not present or not a repository; skipping";
-        }
-    }
-    for my $pkg (`cat libraries/core-packages libraries/extra-packages`) {
-        chomp $pkg;
-        if (-d "libraries/$pkg") {
-            darcs (@_, "--repodir", "libraries/$pkg");
-        }
-        else {
-            warning("$pkg doesn't exist, use 'darcs-all get' to get it");
-        }
-    }
-}
-
-sub darcsgetpackage {
-    my ($get_it, $r_flags, $repo_root, $package) = @_;
-
-    if ($get_it) {
-        if (-d $package) {
-            warning("$package already present; omitting");
+    my $localpath;
+    my $path;
+    my $tag;
+    my @repos;
+
+    open IN, "< packages" or die "Can't open packages file";
+    @repos = <IN>;
+    close IN;
+
+    foreach (@repos) {
+        chomp;
+        if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
+            $localpath = $1;
+            $tag = defined($2) ? $2 : "";
+
+            if (-d "$localpath/_darcs") {
+                darcs (@_, "--repodir", $localpath);
+            }
+            elsif ($tag eq "") {
+                message "== Required repo $localpath is missing! Skipping";
+            }
+            else {
+                message "== $localpath repo not present; skipping";
+            }
         }
-        else {
-            darcs (@$r_flags, "$repo_root/$package");
+        elsif (! /^(#.*)?$/) {
+            die "Bad line: $_";
         }
     }
 }
 
 sub darcsget {
     my $r_flags;
+    my $localpath;
+    my $remotepath;
+    my $path;
+    my $tag;
+    my @repos;
+
     if (! grep /(?:--complete|--partial)/, @_) {
         warning("adding --partial, to override use --complete");
         $r_flags = [@_, "--partial"];
@@ -105,22 +117,41 @@ sub darcsget {
         $r_flags = \@_;
     }
 
-    darcsgetpackage($nofib,     $r_flags, $defaultrepo_base, "nofib");
-    darcsgetpackage($testsuite, $r_flags, $defaultrepo_base, "testsuite");
+    open IN, "< packages" or die "Can't open packages file";
+    @repos = <IN>;
+    close IN;
 
-    chdir "libraries";
+    foreach (@repos) {
+        chomp;
+        if (/^([^ ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
+            $localpath = $1;
+            $tag = defined($2) ? $2 : "";
+            $remotepath = $3;
 
-    my @packages;
-    if ($extra) {
-        @packages = `cat core-packages extra-packages`;
-    }
-    else {
-        @packages = `cat core-packages`;
-    }
+            if ($checked_out_tree) {
+                $path = "$defaultrepo_base/$localpath";
+            }
+            else {
+                if ($remotepath =~ /^http:/) {
+                    $path = $remotepath;
+                }
+                else {
+                    $path = "$defaultrepo_base/$remotepath";
+                }
+            }
 
-    for my $pkg (@packages) {
-        chomp $pkg;
-        darcsgetpackage(1, $r_flags, $defaultrepo_lib, $pkg);
+            if (($tag eq "") || defined($tags{$tag})) {
+                if (-d $localpath) {
+                    warning("$localpath already present; omitting");
+                }
+                else {
+                    darcs (@$r_flags, $path, $localpath);
+                }
+            }
+        }
+        elsif (! /^(#.*)?$/) {
+            die "Bad line: $_";
+        }
     }
 }
 
@@ -139,14 +170,15 @@ sub main {
         elsif ($arg eq "-s") {
             $verbose = 0;
         }
-        elsif ($arg eq "--extra") {
-            $extra = 1;
-        }
+        # --nofib tells get to also grab the nofib repo.
+        # It has no effect on the other commands.
         elsif ($arg eq "--nofib") {
-            $nofib = 1;
+            $tags{"nofib"} = 1;
         }
+        # --testsuite tells get to also grab the testsuite repo.
+        # It has no effect on the other commands.
         elsif ($arg eq "--testsuite") {
-            $testsuite = 1;
+            $tags{"testsuite"} = 1;
         }
         else {
             unshift @_, $arg;