X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=sync-all;h=5336e29af71579aeb62a85afb00635b2c3599b42;hp=930cfd2c5e086b5599d6952a5424e470d04e0fd1;hb=3463ec6781e091e584fd216157c3247c3d3d5865;hpb=ed9482bcecb932a016a0f1da6fcfe78f8c74b7eb diff --git a/sync-all b/sync-all old mode 100644 new mode 100755 index 930cfd2..5336e29 --- a/sync-all +++ b/sync-all @@ -3,22 +3,12 @@ use strict; use Cwd; -# Figure out where to get the other repositories from, -# based on where this GHC repo came from. -my $branch = `git branch | grep "\* " | sed "s/^\* //"`; chomp $branch; -my $remote = `git config branch.$branch.remote`; chomp $remote; -my $defaultrepo = `git config remote.$remote.url`; chomp $defaultrepo; - -my $defaultrepo_base; -my $checked_out_tree; - +my $defaultrepo; my @packages; - my $verbose = 2; my $ignore_failure = 0; my $want_remote_repo = 0; my $checked_out_flag = 0; - my $get_mode; # Flags specific to a particular command @@ -29,8 +19,18 @@ 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; + + if (defined($defaultrepo)) { + $repo = $defaultrepo; + chomp $repo; + } else { + # Figure out where to get the other repositories from, + # based on where this GHC repo came from. + my $branch = `git branch | grep "\* " | sed "s/^\* //"`; chomp $branch; + my $remote = `git config branch.$branch.remote`; chomp $remote; + $repo = `git config remote.$remote.url`; chomp $repo; + } my $repo_base; my $checked_out_tree; @@ -79,7 +79,7 @@ sub parsePackages { my @repos; my $lineNum; - open IN, "< packages.git" or die "Can't open packages file"; + open IN, "< packages" or die "Can't open packages file"; @repos = ; close IN; @@ -116,12 +116,25 @@ sub warning { } sub scm { + my $dir = shift; my $scm = shift; - - message "== running $scm @_"; + my $pwd; + + if ($dir eq '.') { + message "== running $scm @_"; + } else { + message "== $dir: running $scm @_"; + $pwd = getcwd(); + chdir($dir); + } + system ($scm, @_) == 0 or $ignore_failure or die "$scm failed: $?"; + + if ($dir ne '.') { + chdir($pwd); + } } sub repoexists { @@ -150,6 +163,8 @@ sub scmall { my @scm_args; + my $pwd; + my ($repo_base, $checked_out_tree) = getrepo(); parsePackages; @@ -223,6 +238,19 @@ sub scmall { or ($scm eq "git" and "send-email")); $want_remote_repo = 1; } + elsif ($command =~ /^set-origin$/) { + @scm_args = ("remote", "set-url", "origin", $path); + } + elsif ($command =~ /^set-push$/) { + @scm_args = ("remote", "set-url", "--push", "origin", $path); + print "foo\n", @scm_args; + } + elsif ($command =~ /^fetch$/) { + @scm_args = ("fetch", "origin"); + } + elsif ($command =~ /^new$/) { + @scm_args = ("log", "origin.."); + } else { die "Unknown command: $command"; } @@ -231,19 +259,20 @@ sub scmall { if (repoexists ($scm, $localpath)) { if ($want_remote_repo) { if ($scm eq "darcs") { - scm ($scm, @scm_args, @_, "--repodir=$localpath", $path); + scm (".", $scm, @scm_args, @_, "--repodir=$localpath", $path); } else { # git pull doesn't like to be used with --work-dir - scm ($scm, "--git-dir=$localpath/.git", @scm_args, @_, $path, "master"); + # I couldn't find an alternative to chdir() here + scm ($localpath, $scm, @scm_args, @_, $path, "master"); } } else { # git status *must* be used with --work-dir, if we don't chdir() to the dir - scm ($scm, "--git-dir=$localpath/.git", "--work-tree=$localpath", @scm_args, @_); + scm ($localpath, $scm, @scm_args, @_); } } elsif ($local_repo_unnecessary) { # Don't bother to change directory in this case - scm ($scm, @scm_args, @_); + scm (".", $scm, @scm_args, @_); } elsif ($tag eq "") { message "== Required repo $localpath is missing! Skipping"; @@ -314,7 +343,11 @@ Supported commands: * -- * --complete * --partial + * fetch * send + * set-origin + * set-push + * new Available package-tags are: END