cvs-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Cvs-cvs] ccvs/src ChangeLog history.c sanity.sh


From: Derek Robert Price
Subject: [Cvs-cvs] ccvs/src ChangeLog history.c sanity.sh
Date: Mon, 11 Jun 2007 15:46:00 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Changes by:     Derek Robert Price <dprice>     07/06/11 15:46:00

Modified files:
        src            : ChangeLog history.c sanity.sh 

Log message:
        * history.c: Output more useful error messages when multiple history
        files are being parsed.
        * sanity.sh: Test this new feature.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&r1=1.3511&r2=1.3512
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/history.c?cvsroot=cvs&r1=1.99&r2=1.100
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/sanity.sh?cvsroot=cvs&r1=1.1177&r2=1.1178

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3511
retrieving revision 1.3512
diff -u -b -r1.3511 -r1.3512
--- ChangeLog   30 May 2007 23:20:42 -0000      1.3511
+++ ChangeLog   11 Jun 2007 15:45:58 -0000      1.3512
@@ -1,3 +1,9 @@
+2007-06-11  Derek Price  <address@hidden>
+
+       * history.c: Output more useful error messages when multiple history
+       files are being parsed.
+       * sanity.sh: Test this new feature.
+
 2007-05-30  Mark D. Baushke  <address@hidden>
 
        * sanity.sh: Add --valgrind command-line option for running the

Index: history.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/history.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -b -r1.99 -r1.100
--- history.c   30 May 2007 23:20:43 -0000      1.99
+++ history.c   11 Jun 2007 15:45:59 -0000      1.100
@@ -220,11 +220,14 @@
     char *mod;         /* The module within which the file is contained */
     time_t date;       /* Calculated from date stored in record */
     long idx;          /* Index of record, for "stable" sort. */
+    const char *source_file_name;  /* For error messages.  */
+    long source_line_num;         /* For error messages.  */
 } *hrec_head;
 static long hrec_idx;
 
 
-static void fill_hrec (char *line, struct hrec * hr);
+static void fill_hrec (const char *source_file_name, long source_line_num,
+                      char *line, struct hrec * hr);
 static int accept_hrec (struct hrec * hr, struct hrec * lr);
 static int select_hrec (struct hrec * hr);
 static int sort_order (const void *l, const void *r);
@@ -1094,7 +1097,8 @@
        } while (0)
 
 static void
-fill_hrec (char *line, struct hrec *hr)
+fill_hrec (const char *source_file_name, long source_line_num,
+          char *line, struct hrec *hr)
 {
     char *cp;
     int c;
@@ -1103,6 +1107,8 @@
        hr->end = hr->mod = NULL;
     hr->date = -1;
     hr->idx = ++hrec_idx;
+    hr->source_file_name = source_file_name;
+    hr->source_line_num = source_line_num;
 
     while (isspace ((unsigned char) *line))
        line++;
@@ -1157,6 +1163,7 @@
     char *hrline;
     int i;
     int fd;
+    long line_num;
     struct stat st_buf;
     const char *fname = p->key;
 
@@ -1181,6 +1188,7 @@
     cpstart = xnmalloc (2, STAT_BLOCKSIZE (st_buf));
     cpstart[0] = '\0';
     cp = cpend = cpstart;
+    line_num = 1;
 
     for (;;)
     {
@@ -1191,8 +1199,8 @@
        {
            if (nl - cp >= STAT_BLOCKSIZE (st_buf))
            {
-               error(1, 0, "history line %ld too long (> %lu)", hrec_idx + 1,
-                     (unsigned long) STAT_BLOCKSIZE(st_buf));
+               error(1, 0, "line %ld of history file `%s' too long (> %lu)",
+                     line_num, fname, (unsigned long) STAT_BLOCKSIZE(st_buf));
            }
            if (nl > cp)
                memmove (cpstart, cp, nl - cp);
@@ -1242,7 +1250,7 @@
           re-write the whole history stuff right now.  */
 
        hrline = xstrdup (cp);
-       fill_hrec (hrline, &hrec_head[hrec_count]);
+       fill_hrec (fname, line_num, hrline, &hrec_head[hrec_count]);
        if (select_hrec (&hrec_head[hrec_count]))
            hrec_count++;
        else 
@@ -1252,6 +1260,7 @@
        }
 
        cp = nl + 1;
+       line_num++;
     }
     free (cpstart);
     close (fd);
@@ -1337,7 +1346,8 @@
     if (!hr->type || !hr->user || !hr->dir || !hr->repos || !hr->rev ||
        !hr->file || !hr->end)
     {
-       error (0, 0, "warning: history line %ld invalid", hr->idx);
+       error (0, 0, "warning: line %ld from history file `%s' invalid",
+              hr->source_line_num, hr->source_file_name);
        return 0;
     }
 

Index: sanity.sh
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/sanity.sh,v
retrieving revision 1.1177
retrieving revision 1.1178
diff -u -b -r1.1177 -r1.1178
--- sanity.sh   30 May 2007 23:20:44 -0000      1.1177
+++ sanity.sh   11 Jun 2007 15:45:59 -0000      1.1178
@@ -21264,14 +21264,21 @@
 
"-rw-rw-r--.*$TESTDIR/historylogs/2[0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]-[0-2][0-9]-[0-5][0-9]-[0-5][0-9]
 
-rw-rw-r--.*$TESTDIR/historylogs/2[0-9][0-9][0-9]-[01][0-9]-[0-3][0-9]-[0-2][0-9]-[0-5][0-9]-[0-5][0-9]"
 
-           # Should still see both commits.
+           echo garbage >$TESTDIR/historylogs/garbage
+           echo more garbage >>$TESTDIR/historylogs/garbage
+
+           # Should still see both commits and the error message.
            if $remote; then
              dotest config-9r "$testcvs history -ea" \
-"M [0-9-]* [0-9:]* ${PLUS}0000 $username 1\.[0-9]* config CVSROOT == <remote>
+"$SPROG history: warning: line 1 from history file 
\`$CVSROOT_DIRNAME/\.\./historylogs/garbage' invalid
+$SPROG history: warning: line 2 from history file 
\`$CVSROOT_DIRNAME/\.\./historylogs/garbage' invalid
+M [0-9-]* [0-9:]* ${PLUS}0000 $username 1\.[0-9]* config CVSROOT == <remote>
 M [0-9-]* [0-9:]* ${PLUS}0000 $username 1\.[0-9]* config CVSROOT == <remote>"
            else
              dotest config-9 "$testcvs history -ea" \
-"M [0-9-]* [0-9:]* ${PLUS}0000 $username 1\.[0-9]* config CVSROOT == 
$TESTDIR/wnt/CVSROOT
+"$SPROG history: warning: line 1 from history file 
\`$CVSROOT_DIRNAME/\.\./historylogs/garbage' invalid
+$SPROG history: warning: line 2 from history file 
\`$CVSROOT_DIRNAME/\.\./historylogs/garbage' invalid
+M [0-9-]* [0-9:]* ${PLUS}0000 $username 1\.[0-9]* config CVSROOT == 
$TESTDIR/wnt/CVSROOT
 M [0-9-]* [0-9:]* ${PLUS}0000 $username 1\.[0-9]* config CVSROOT == 
$TESTDIR/wnt/CVSROOT"
            fi
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]