Give clearer errors for bad input in the packages file; suggested by pejo
[ghc-hetmet.git] / darcs-all
index 72aff54..b4ba47e 100644 (file)
--- a/darcs-all
+++ b/darcs-all
@@ -157,6 +157,7 @@ sub darcsall {
     my $tag;
     my @repos;
     my $command = $_[0];
+    my $line;
 
     my ($repo_base, $checked_out_tree) = getrepo();
 
@@ -164,11 +165,13 @@ sub darcsall {
     @repos = <IN>;
     close IN;
 
+    $line = 0;
     foreach (@repos) {
         chomp;
-        if (/^([^# ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
+        $line++;
+        if (/^([^# ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)$/) {
             $localpath = $1;
-            $tag = defined($2) ? $2 : "";
+            $tag = $2;
             $remotepath = $3;
 
             if ($checked_out_tree) {
@@ -190,7 +193,7 @@ sub darcsall {
                     darcs (@_, "--repodir", $localpath);
                 }
             }
-            elsif ($tag eq "") {
+            elsif ($tag eq "-") {
                 message "== Required repo $localpath is missing! Skipping";
             }
             else {
@@ -198,7 +201,7 @@ sub darcsall {
             }
         }
         elsif (! /^(#.*)?$/) {
-            die "Bad line: $_";
+            die "Bad content on line $line of packages file: $_";
         }
     }
 }
@@ -210,6 +213,7 @@ sub darcsget {
     my $path;
     my $tag;
     my @repos;
+    my $line;
 
     my ($repo_base, $checked_out_tree) = getrepo();
 
@@ -225,11 +229,13 @@ sub darcsget {
     @repos = <IN>;
     close IN;
 
+    $line = 0;
     foreach (@repos) {
         chomp;
-        if (/^([^ ]+) +(?:([^ ]+) +)?([^ ]+) +([^ ]+)$/) {
+        $line++;
+        if (/^([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)$/) {
             $localpath = $1;
-            $tag = defined($2) ? $2 : "";
+            $tag = $2;
             $remotepath = $3;
 
             if ($checked_out_tree) {
@@ -239,7 +245,7 @@ sub darcsget {
                 $path = "$repo_base/$remotepath";
             }
 
-            if (($tag eq "") || defined($tags{$tag})) {
+            if (($tag eq "-") || defined($tags{$tag})) {
                 if (-d $localpath) {
                     warning("$localpath already present; omitting");
                 }
@@ -249,7 +255,7 @@ sub darcsget {
             }
         }
         elsif (! /^(#.*)?$/) {
-            die "Bad line: $_";
+            die "Bad content on line $line of packages file: $_";
         }
     }
 }