From db485571de4216b379fad54b377fa970d204bcae Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Tue, 5 Apr 2011 11:02:40 +0100 Subject: [PATCH] Add "remote add" and "remote rm" commands To add and delete remote branches from all subrepos. e.g. ./sync-all -r ~/git/ghc-working remote add working ./sync-all remote rm working --- sync-all | 111 ++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 42 deletions(-) diff --git a/sync-all b/sync-all index 685c3b6..e4cb40e 100755 --- a/sync-all +++ b/sync-all @@ -215,6 +215,8 @@ sub scmall { my $scm; my $upstream; my $line; + my $branch_name; + my $subcommand; my $path; my $wd_before = getcwd; @@ -227,6 +229,17 @@ sub scmall { parsePackages; + if ($command =~ /^remote$/) { + if (@_ < 2) { + help(); + } + $subcommand = shift; + $branch_name = shift; + if ($subcommand ne 'add' && $subcommand ne 'rm') { + help(); + } + } + for $line (@packages) { $localpath = $$line{"localpath"}; @@ -301,7 +314,6 @@ sub scmall { } elsif ($command =~ /^set-push$/) { @scm_args = ("remote", "set-url", "--push", "origin", $path); - print "foo\n", @scm_args; } elsif ($command =~ /^fetch$/) { @scm_args = ("fetch", "origin"); @@ -309,6 +321,13 @@ sub scmall { elsif ($command =~ /^new$/) { @scm_args = ("log", "origin.."); } + elsif ($command =~ /^remote$/) { + if ($subcommand eq 'add') { + @scm_args = ("remote", "add", $branch_name, $path); + } elsif ($subcommand eq 'rm') { + @scm_args = ("remote", "rm", $branch_name); + } + } else { die "Unknown command: $command"; } @@ -341,6 +360,54 @@ sub scmall { } } + +sub help() +{ + # Get the built in help + my $help = < + * --complete + * --partial + * fetch + * send + * set-origin + * set-push + * new + * remote add + * remote rm + +Available package-tags are: +END + + # Collect all the tags in the packages file + my %available_tags; + open IN, "< packages" or die "Can't open packages file"; + while () { + chomp; + if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)/) { + if (defined($2) && $2 ne "-") { + $available_tags{$2} = 1; + } + } + elsif (! /^(#.*)?$/) { + die "Bad line: $_"; + } + } + close IN; + + # Show those tags and the help text + my @available_tags = keys %available_tags; + print "$help@available_tags\n"; + exit 1; +} + sub main { if (! -d ".git" || ! -d "compiler") { die "error: sync-all must be run from the top level of the ghc tree." @@ -389,47 +456,7 @@ sub main { } if ($#_ eq -1) { - # Get the built in help - my $help = < - * --complete - * --partial - * fetch - * send - * set-origin - * set-push - * new - -Available package-tags are: -END - - # Collect all the tags in the packages file - my %available_tags; - open IN, "< packages" or die "Can't open packages file"; - while () { - chomp; - if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)/) { - if (defined($2) && $2 ne "-") { - $available_tags{$2} = 1; - } - } - elsif (! /^(#.*)?$/) { - die "Bad line: $_"; - } - } - close IN; - - # Show those tags and the help text - my @available_tags = keys %available_tags; - print "$help@available_tags\n"; - exit 1; + help(); } else { # Give the command and rest of the arguments to the main loop -- 1.7.10.4