X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=sync-all;h=ac06af123a5d4c4eae68b3a5551134ae5833f1d9;hp=360d6fa6526d65cc2b8be2b682635cf6b30126e4;hb=e5c3b478b3cd1707cf122833822f44b2ac09b8e9;hpb=0885017a4e92fe5710d1427c214adb87b92987e5 diff --git a/sync-all b/sync-all index 360d6fa..ac06af1 100755 --- a/sync-all +++ b/sync-all @@ -68,9 +68,6 @@ my $ignore_failure = 0; my $checked_out_flag = 0; my $get_mode; -# Flags specific to a particular command -my $local_repo_unnecessary = 0; - my %tags; # Figure out where to get the other repositories from. @@ -145,13 +142,12 @@ sub parsePackages { foreach (@repos) { chomp; $lineNum++; - if (/^([^# ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)$/) { + if (/^([^# ]+) +([^ ]+) +([^ ]+) +([^ ]+)$/) { my %line; $line{"localpath"} = $1; $line{"tag"} = $2; $line{"remotepath"} = $3; $line{"vcs"} = $4; - $line{"upstream"} = $5; push @packages, \%line; } elsif (! /^(#.*)?$/) { @@ -201,7 +197,6 @@ sub scmall { my $tag; my $remotepath; my $scm; - my $upstream; my $line; my $branch_name; my $subcommand; @@ -209,8 +204,6 @@ sub scmall { my $path; my $wd_before = getcwd; - my @scm_args; - my $pwd; my @args; @@ -241,7 +234,7 @@ sub scmall { } else { $branch_name = shift; } - } elsif ($command eq 'new' || $command eq 'fetch') { + } elsif ($command eq 'new') { if (@_ < 1) { $branch_name = 'origin'; } else { @@ -257,7 +250,6 @@ sub scmall { $tag = $$line{"tag"}; $remotepath = $$line{"remotepath"}; $scm = $$line{"vcs"}; - $upstream = $$line{"upstream"}; # Check the SCM is OK as early as possible die "Unknown SCM: $scm" if (($scm ne "darcs") and ($scm ne "git")); @@ -288,29 +280,26 @@ sub scmall { if (-d $localpath) { warning("$localpath already present; omitting") if $localpath ne "."; + if ($scm eq "git") { + scm ($localpath, $scm, "config", "core.ignorecase", "true"); + } next; } - - # The first time round the loop, default the get-mode - if ($scm eq "darcs" && not defined($get_mode)) { - warning("adding --partial, to override use --complete"); - $get_mode = "--partial"; - } - - # The only command that doesn't need a repo - $local_repo_unnecessary = 1; - + + # Note that we use "." as the path, as $localpath + # doesn't exist yet. if ($scm eq "darcs") { - # Note: we can only use the get-mode with darcs for now - @scm_args = ("get", $get_mode, $path, $localpath); + # The first time round the loop, default the get-mode + if (not defined($get_mode)) { + warning("adding --partial, to override use --complete"); + $get_mode = "--partial"; + } + scm (".", $scm, "get", $get_mode, $path, $localpath, @args); } else { - @scm_args = ("clone", $path, $localpath); + scm (".", $scm, "clone", $path, $localpath, @args); + scm ($localpath, $scm, "config", "core.ignorecase", "true"); } - - # Note that we use "." as the path, as $localpath - # doesn't exist yet. - scm (".", $scm, @scm_args, @args); next; } @@ -318,52 +307,67 @@ sub scmall { if (-d "$localpath/.git") { die "Found both _darcs and .git in $localpath"; } - else { - $scm = "darcs"; - } + $scm = "darcs"; + } elsif (-d "$localpath/.git") { + $scm = "git"; + } elsif ($tag eq "") { + die "Required repo $localpath is missing"; + } else { + message "== $localpath repo not present; skipping"; + next; } - else { - if (-d "$localpath/.git") { - $scm = "git"; + + # Work out the arguments we should give to the SCM + if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew|status)$/) { + if ($scm eq "darcs") { + $command = "whatsnew"; } - elsif ($tag eq "") { - die "Required repo $localpath is missing"; + elsif ($scm eq "git") { + $command = "status"; } else { - message "== $localpath repo not present; skipping"; + die "Unknown scm"; } - } - # Work out the arguments we should give to the SCM - if ($command =~ /^(?:w|wh|wha|what|whats|whatsn|whatsne|whatsnew|status)$/) { - @scm_args = (($scm eq "darcs" and "whatsnew") - or ($scm eq "git" and "status")); - # Hack around 'darcs whatsnew' failing if there are no changes $ignore_failure = 1; + scm ($localpath, $scm, $command, @args); } elsif ($command =~ /^commit$/) { - @scm_args = ("commit"); # git fails if there is nothing to commit, so ignore failures $ignore_failure = 1; + scm ($localpath, $scm, "commit", @args); } elsif ($command =~ /^(?:pus|push)$/) { - @scm_args = "push"; + scm ($localpath, $scm, "push", @args); } elsif ($command =~ /^(?:pul|pull)$/) { - @scm_args = "pull"; + scm ($localpath, $scm, "pull", @args); } elsif ($command =~ /^(?:s|se|sen|send)$/) { - @scm_args = (($scm eq "darcs" and "send") - or ($scm eq "git" and "send-email")); + if ($scm eq "darcs") { + $command = "send"; + } + elsif ($scm eq "git") { + $command = "send-email"; + } + else { + die "Unknown scm"; + } + scm ($localpath, $scm, $command, @args); } elsif ($command =~ /^fetch$/) { - @scm_args = ("fetch", "$branch_name"); + scm ($localpath, $scm, "fetch", @args); } elsif ($command =~ /^new$/) { - @scm_args = ("log", "$branch_name.."); + my @scm_args = ("log", "$branch_name.."); + scm ($localpath, $scm, @scm_args, @args); + } + elsif ($command =~ /^log$/) { + scm ($localpath, $scm, "log", @args); } elsif ($command =~ /^remote$/) { + my @scm_args; if ($subcommand eq 'add') { @scm_args = ("remote", "add", $branch_name, $path); } elsif ($subcommand eq 'rm') { @@ -371,24 +375,35 @@ sub scmall { } elsif ($subcommand eq 'set-url') { @scm_args = ("remote", "set-url", $branch_name, $path); } + scm ($localpath, $scm, @scm_args, @args); + } + elsif ($command =~ /^checkout$/) { + # Not all repos are necessarily branched, so ignore failure + $ignore_failure = 1; + scm ($localpath, $scm, "checkout", @args) + unless $scm eq "darcs"; } elsif ($command =~ /^grep$/) { - @scm_args = ("grep"); - # Hack around 'git grep' failing if there are no matches - $ignore_failure = 1; + # Hack around 'git grep' failing if there are no matches + $ignore_failure = 1; + scm ($localpath, $scm, "grep", @args) + unless $scm eq "darcs"; + } + elsif ($command =~ /^clean$/) { + scm ($localpath, $scm, "clean", @args) + unless $scm eq "darcs"; } elsif ($command =~ /^reset$/) { - @scm_args = "reset"; + scm ($localpath, $scm, "reset", @args) + unless $scm eq "darcs"; } elsif ($command =~ /^config$/) { - @scm_args = "config"; + scm ($localpath, $scm, "config", @args) + unless $scm eq "darcs"; } else { die "Unknown command: $command"; } - - # Actually execute the command - scm ($localpath, $scm, @scm_args, @args); } } @@ -414,9 +429,12 @@ Supported commands: * remote add * remote rm * remote set-url [--push] + * checkout * grep + * clean * reset * config + * log Available package-tags are: END