Commit db485571 authored by Simon Marlow's avatar Simon Marlow

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
parent 3a50b1f6
......@@ -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 = <<END;
What do you want to do?
Supported commands:
* whatsnew
* push
* pull
* get, with options:
* --<package-tag>
* --complete
* --partial
* fetch
* send
* set-origin
* set-push
* new
* remote add <branch-name>
* remote rm <branch-name>
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 (<IN>) {
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 = <<END;
What do you want to do?
Supported commands:
* whatsnew
* push
* pull
* get, with options:
* --<package-tag>
* --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 (<IN>) {
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment