summaryrefslogtreecommitdiff
path: root/sync-all
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2011-07-15 22:14:33 +0100
committerIan Lynagh <igloo@earth.li>2011-07-15 22:14:33 +0100
commitbcda801d61c48f536af53b75815d4d2bd2abded4 (patch)
tree1c91b6e7f5c88b8b427b868e94d8087b2e533e86 /sync-all
parent83e8244fc16182d28a7b4e6357984051cd089f06 (diff)
downloadhaskell-bcda801d61c48f536af53b75815d4d2bd2abded4.tar.gz
Add --resume support to sync-all; trac #5119
Now after, for example, "./sync-all pull", if pulling in one repo fails then you can restart from that point with "./sync-all --resume pull".
Diffstat (limited to 'sync-all')
-rwxr-xr-xsync-all50
1 files changed, 49 insertions, 1 deletions
diff --git a/sync-all b/sync-all
index 6c4396534a..deb971ff9a 100755
--- a/sync-all
+++ b/sync-all
@@ -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;
}