X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=darcs-all;h=1a0e639a4789661e2e733d235af496aa63ac2ceb;hb=7327a270b60b18ba6d8a4a73a7a288a69dac5eff;hp=bb417060e51b3e9c0f01cef1da5adcb47a4ed012;hpb=cc002579bf0b49bd5a5f2a00dd7100c94a3f81e9;p=ghc-hetmet.git diff --git a/darcs-all b/darcs-all index bb41706..1a0e639 100644 --- a/darcs-all +++ b/darcs-all @@ -2,36 +2,76 @@ use strict; -# 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 $checked_out_tree; - -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#/[^/]+/?$##; - $checked_out_tree = 0; -} -elsif ($defaultrepo =~ /^(\.\.)?\//) { - # Local filesystem, either absolute or relative path - # (assumes a checked-out tree): - $defaultrepo_base = $defaultrepo; - $checked_out_tree = 1; -} -else { - die "Couldn't work out defaultrepo"; -} +# Usage: +# +# ./darcs-all [-q] [-s] [-i] [-r repo] [--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. +# -i says to ignore darcs errors and move on to the next repository +# -r repo says to use repo as the location of package repositories +# --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] [-i] [-r repo] 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 + +my $defaultrepo; my $verbose = 2; my $ignore_failure = 0; +my $want_remote_repo = 0; my %tags; +# Figure out where to get the other repositories from. +sub getrepo { + my $basedir = "."; + my $repo = $defaultrepo || `cat $basedir/_darcs/prefs/defaultrepo`; + chomp $repo; + + my $repo_base; + my $checked_out_tree; + + if ($repo =~ /^...*:/) { + # HTTP or SSH + # Above regex says "at least two chars before the :", to avoid + # catching Win32 drives ("C:\"). + $repo_base = $repo; + $checked_out_tree = 0; + + # Don't drop the last part of the path if specified with -r, as + # it expects repos of the form: + # + # http://darcs.haskell.org + # + # rather than + # + # http://darcs.haskell.org/ghc + # + if (!$defaultrepo) { + $repo_base =~ s#/[^/]+/?$##; + } + } + elsif ($repo =~ /^\/|\.\.\/|.:(\/|\\)/) { + # Local filesystem, either absolute or relative path + # (assumes a checked-out tree): + $repo_base = $repo; + $checked_out_tree = 1; + } + else { + die "Couldn't work out repo"; + } + + return $repo_base, $checked_out_tree; +} + sub message { if ($verbose >= 2) { print "@_\n"; @@ -47,26 +87,43 @@ sub warning { sub darcs { message "== running darcs @_"; system ("darcs", @_) == 0 - or $ignore_failure - or die "darcs failed: $?"; + or $ignore_failure + or die "darcs failed: $?"; } sub darcsall { my $localpath; + my $remotepath; my $path; my $tag; + my @repos; - darcs @_; + my ($repo_base, $checked_out_tree) = getrepo(); open IN, "< packages" or die "Can't open packages file"; - while () { + @repos = ; + close IN; + + REPO: foreach (@repos) { chomp; - if (/^([^ ]+) +(?:([^ ]+) +)?([^ ]+)/) { + if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) { $localpath = $1; $tag = defined($2) ? $2 : ""; + $remotepath = $3; + + if ($checked_out_tree) { + $path = "$repo_base/$localpath"; + } + else { + $path = "$repo_base/$remotepath"; + } if (-d "$localpath/_darcs") { - darcs (@_, "--repodir", $localpath); + if ($want_remote_repo) { + darcs (@_, "--repodir", $localpath, $path); + } else { + darcs (@_, "--repodir", $localpath); + } } elsif ($tag eq "") { message "== Required repo $localpath is missing! Skipping"; @@ -75,11 +132,10 @@ sub darcsall { message "== $localpath repo not present; skipping"; } } - elsif (! /^$/) { + elsif (! /^(#.*)?$/) { die "Bad line: $_"; } } - close IN; } sub darcsget { @@ -88,6 +144,9 @@ sub darcsget { my $remotepath; my $path; my $tag; + my @repos; + + my ($repo_base, $checked_out_tree) = getrepo(); if (! grep /(?:--complete|--partial)/, @_) { warning("adding --partial, to override use --complete"); @@ -98,18 +157,21 @@ sub darcsget { } open IN, "< packages" or die "Can't open packages file"; - while () { + @repos = ; + close IN; + + foreach (@repos) { chomp; - if (/^([^ ]+) +(?:([^ ]+) +)?([^ ]+)/) { + if (/^([^ ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) { $localpath = $1; $tag = defined($2) ? $2 : ""; $remotepath = $3; if ($checked_out_tree) { - $path = "$defaultrepo_base/$localpath"; + $path = "$repo_base/$localpath"; } else { - $path = "$defaultrepo_base/$remotepath"; + $path = "$repo_base/$remotepath"; } if (($tag eq "") || defined($tags{$tag})) { @@ -121,15 +183,14 @@ sub darcsget { } } } - elsif (! /^$/) { + elsif (! /^(#.*)?$/) { die "Bad line: $_"; } } - close IN; } sub main { - if (! -d "_darcs" || ! -d "compiler") { + if (! -d "compiler") { die "error: darcs-all must be run from the top level of the ghc tree." } @@ -143,16 +204,11 @@ sub main { elsif ($arg eq "-s") { $verbose = 0; } - # --ci says we grab cabal-install repo, and the libraries it needs - # with 'get'. - # It has no effect on the other commands. - elsif ($arg eq "--ci") { - $tags{"ci"} = 1; + elsif ($arg eq "-r") { + $defaultrepo = shift; } - # --extra says we grab the extra libs with 'get'. - # It has no effect on the other commands. - elsif ($arg eq "--extra") { - $tags{"extralibs"} = 1; + elsif ($arg eq "-i") { + $ignore_failure = 1; } # --nofib tells get to also grab the nofib repo. # It has no effect on the other commands. @@ -185,6 +241,9 @@ sub main { # Hack around whatsnew failing if there are no changes $ignore_failure = 1; } + if ($command =~ /^(pul|pus|sen|put)/) { + $want_remote_repo = 1; + } darcsall @_; } }