chiark / gitweb /
More comprehensive warnings in many cases of archive skew.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 11 Sep 2013 23:10:50 +0000 (00:10 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 11 Sep 2013 23:10:50 +0000 (00:10 +0100)
debian/changelog
dgit

index 507d2c1396852619734f00ff740bf14c99fe50e0..89b5c1f6e23b9f3c4c5aea72ce7b5de2d725b883 100644 (file)
@@ -4,6 +4,7 @@ dgit (0.15) unstable; urgency=low
   * Provide `dgit version' and `--version'.  Closes: #721654.
   * Better handling of packages pushed using dgit and stuck in NEW.
     (And, use of `--new' is not needed with fetch.)  Closes: #722199.
+  * More comprehensive warnings in many cases of archive skew.
 
  --
 
diff --git a/dgit b/dgit
index 123c2d513ae2cc05f3f3dd82a90c06a3b64202bd..1838f2fb9e7849ff8d62013cd67ddb6a4375fd81 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -131,7 +131,7 @@ sub url_get {
     return $r->decoded_content();
 }
 
-our ($dscdata,$dscurl,$dsc);
+our ($dscdata,$dscurl,$dsc,$skew_warning_vsn);
 
 sub printcmd {
     my $fh = shift @_;
@@ -450,7 +450,10 @@ sub get_archive_dsc () {
        my ($vsn,$subpath) = @$vinfo;
        $dscurl = access_cfg('mirror').$subpath;
        $dscdata = url_get($dscurl);
-       next unless defined $dscdata;
+       if (!$dscdata) {
+           $skew_warning_vsn = $vsn if !defined $skew_warning_vsn;
+           next;
+       }
        my $dscfh = new IO::File \$dscdata, '<' or die $!;
        print DEBUG Dumper($dscdata) if $debug>1;
        $dsc = parsecontrolfh($dscfh,$dscurl, allow_pgp=>1);
@@ -750,12 +753,20 @@ END
        $hash = $lastpush_hash;
        print STDERR <<END or die $!;
 
-Package not found in the archive, but has allegedly been
-pushed/uploaded using dgit.
+Package not found in the archive, but has allegedly been pushed using dgit.
 $later_warning_msg
 END
     } else {
        print DEBUG "nothing found!\n";
+       if (defined $skew_warning_vsn) {
+           print STDERR <<END or die $!;
+
+Warning: relevant archive skew detected.
+Archive allegedly contains $skew_warning_vsn
+But we were not able to obtain any version from the archive or git.
+
+END
+       }
        return 0;
     }
     print DEBUG "current hash=$hash\n";
@@ -764,6 +775,25 @@ END
            " (archive's version left in DGIT_ARCHIVE)"
            unless is_fast_fwd($lastpush_hash, $hash);
     }
+    if (defined $skew_warning_vsn) {
+       mkpath '.git/dgit';
+       print DEBUG "SKEW CHECK WANT $skew_warning_vsn\n";
+       my $clogf = ".git/dgit/changelog.tmp";
+       runcmd shell_cmd "exec >$clogf",
+           @git, qw(cat-file blob), "$hash:debian/changelog";
+       my $gotclogp = parsechangelog("-l$clogf");
+       my $got_vsn = getfield $gotclogp, 'Version';
+       print DEBUG "SKEW CHECK GOT $got_vsn\n";
+       if (version_compare_string($got_vsn, $skew_warning_vsn) < 0) {
+           print STDERR <<END or die $!;
+
+Warning: archive skew detected.  Using the available version:
+Archive allegedly contains    $skew_warning_vsn
+We were able to obtain only   $got_vsn
+
+END
+       }
+    }
     if ($lastpush_hash ne $hash) {
        my @upd_cmd = (@git, qw(update-ref -m), 'dgit fetch', lrref(), $hash);
        if (!$dryrun) {