diff options
Diffstat (limited to 'sync-all')
-rwxr-xr-x | sync-all | 50 |
1 files changed, 49 insertions, 1 deletions
@@ -6,7 +6,7 @@ use Cwd; # Usage: # # ./sync-all [-q] [-s] [--ignore-failure] [-r repo] [--checked-out] [--bare] -# [--nofib] [--extra] [--testsuite] cmd [git flags] +# [--nofib] [--extra] [--testsuite] [--resume] cmd [git flags] # # Applies the command "cmd" to each repository in the tree. # sync-all will try to do the right thing for both git and darcs repositories. @@ -21,6 +21,11 @@ use Cwd; # -------------- Flags ------------------- # -q says to be quite, and -s to be silent. # +# --resume will restart a command that failed, from the repo at which +# it failed. This means you don't need to wait while, e.g., "pull" +# goes through all the repos it's just pulled, and tries to pull them +# again. +# # --ignore-failure says to ignore errors and move on to the next repository # # -r repo says to use repo as the location of package repositories @@ -70,6 +75,7 @@ $| = 1; # autoflush stdout after each print, to avoid output after die my $defaultrepo; my @packages; my $verbose = 2; +my $try_to_resume = 0; my $ignore_failure = 0; my $checked_out_flag = 0; # NOT the opposite of bare_flag (describes remote repo state) my $get_mode; @@ -229,6 +235,10 @@ sub scmall { my $pwd; my @args; + my $started; + my $doing; + my $start_repo; + my ($repo_base, $checked_out_tree) = getrepo(); my $is_github_repo = $repo_base =~ m/(git@|git:\/\/|https:\/\/)github.com/; @@ -266,6 +276,24 @@ sub scmall { push(@args, @_); + # $doing is a good enough approximation to what we are doing that + # we can use it to check that --resume is resuming the right command + $doing = join(" ", ($command, @args)); + $started = 1; + if ($try_to_resume && -f "resume") { + my $what; + open RESUME, "< resume" + or die "Can't open resume file"; + $start_repo = <RESUME>; + chomp $start_repo; + $what = <RESUME>; + chomp $what; + close RESUME; + if ($what eq $doing) { + $started = 0; + } + } + for $line (@packages) { $tag = $$line{"tag"}; $scm = $$line{"vcs"}; @@ -275,6 +303,21 @@ sub scmall { $remotepath = ($checked_out_tree) ? $$line{"localpath"} : $$line{"remotepath"}; + if (!$started) { + if ($start_repo eq $localpath) { + $started = 1; + } + else { + next; + } + } + + open RESUME, "> resume.tmp"; + print RESUME "$localpath\n"; + print RESUME "$doing\n"; + close RESUME; + rename "resume.tmp", "resume"; + # Check the SCM is OK as early as possible die "Unknown SCM: $scm" if (($scm ne "darcs") and ($scm ne "git")); @@ -429,6 +472,8 @@ sub scmall { die "Unknown command: $command"; } } + + unlink "resume"; } sub help() @@ -512,6 +557,9 @@ sub main { elsif ($arg eq "-r") { $defaultrepo = shift; } + elsif ($arg eq "--resume") { + $try_to_resume = 1; + } elsif ($arg eq "--ignore-failure") { $ignore_failure = 1; } |