cvs-cvs
[Top][All Lists]
Advanced

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

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


From: Derek Robert Price
Subject: [Cvs-cvs] ccvs/src ChangeLog repos.c sanity.sh
Date: Mon, 22 Sep 2008 18:01:03 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Changes by:     Derek Robert Price <dprice>     08/09/22 18:01:02

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

Log message:
        * repos.c (Name_Repository): Clean up and simplify.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&r1=1.3611&r2=1.3612
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/repos.c?cvsroot=cvs&r1=1.45&r2=1.46
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/sanity.sh?cvsroot=cvs&r1=1.1209&r2=1.1210

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3611
retrieving revision 1.3612
diff -u -b -r1.3611 -r1.3612
--- ChangeLog   22 Sep 2008 17:36:26 -0000      1.3611
+++ ChangeLog   22 Sep 2008 18:01:00 -0000      1.3612
@@ -1,5 +1,7 @@
 2008-09-22  Derek R. Price  <address@hidden>
 
+       * repos.c (Name_Repository): Clean up and simplify.
+
        * log.c, main.c, remove.c: Some cleanup.
        * rcs.c: Likewise.
        (locate_rcs): Export.  Change int arg to bool.

Index: repos.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/repos.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- repos.c     17 Sep 2008 19:53:30 -0000      1.45
+++ repos.c     22 Sep 2008 18:01:01 -0000      1.46
@@ -19,25 +19,27 @@
 /* Verify interface.  */
 #include "repos.h"
 
-/* CVS headers.  */
+/* GNULIB */
+#include "quote.h"
+
+/* CVS */
 #include "cvs.h"
 
 
 
 /* Determine the name of the RCS repository for directory DIR in the
-   current working directory, or for the current working directory
-   itself if DIR is NULL.  Returns the name in a newly-malloc'd
-   string.  On error, gives a fatal error and does not return.
-   UPDATE_DIR is the path from where cvs was invoked (for use in error
-   messages), and should contain DIR as its last component.
-   UPDATE_DIR can be NULL to signify the directory in which cvs was
-   invoked.  */
-
+ * current working directory, or for the current working directory
+ * itself if DIR is NULL.  Returns the name in a newly-malloc'd
+ * string.  On error, gives a fatal error and does not return.
+ * UPDATE_DIR is the path from where cvs was invoked (for use in error
+ * messages), and should contain DIR as its last component.
+ * UPDATE_DIR can be NULL to signify the directory in which cvs was
+ * invoked.
+ */
 char *
 Name_Repository (const char *dir, const char *update_dir)
 {
     FILE *fpin;
-    const char *xupdate_dir;
     char *repos = NULL;
     size_t repos_allocated = 0;
     char *tmp;
@@ -46,93 +48,79 @@
     TRACE (TRACE_FUNCTION, "Name_Repository (%s, %s)",
           TRACE_NULL (dir), update_dir);
 
-    if (update_dir && *update_dir)
-       xupdate_dir = update_dir;
-    else
-       xupdate_dir = ".";
-
-    if (dir != NULL)
-       tmp = Xasprintf ("%s/%s", dir, CVSADM_REP);
-    else
-       tmp = xstrdup (CVSADM_REP);
+    tmp = dir_append (dir, CVSADM_REP);  /* dir may be NULL */
 
-    /*
-     * The assumption here is that the repository is always contained in the
+    /* The assumption here is that the repository is always contained in the
      * first line of the "Repository" file.
      */
     fpin = CVS_FOPEN (tmp, "r");
-
-    if (fpin == NULL)
+    if (!fpin)
     {
        int save_errno = errno;
        char *cvsadm;
+       char *file = dir_append (update_dir, CVSADM);
 
-       if (dir != NULL)
-           cvsadm = Xasprintf ("%s/%s", dir, CVSADM);
-       else
-           cvsadm = xstrdup (CVSADM);
-
+       cvsadm = dir_append (dir, CVSADM);
        if (!isdir (cvsadm))
        {
-           error (0, 0, "in directory `%s':", xupdate_dir);
-           error (1, 0, "there is no version here; do `%s checkout' first",
-                  program_name);
+           error (1, 0, "admin directory %s is missing; do %s first",
+                  quote_n (0, file),
+                  quote_n (1, Xasprintf ("%s checkout", program_name)));
+           /* NOT REACHED */
        }
-       free (cvsadm);
 
        if (existence_error (save_errno))
        {
            /* This occurs at least in the case where the user manually
             * creates a directory named CVS.
             */
-           error (0, 0, "in directory `%s':", xupdate_dir);
-           error (0, 0, "CVS directory found without administrative files.");
+           error (0, 0,
+                  "admin directory %s found without administrative files.",
+                  quote (file));
            error (0, 0, "Use CVS to create the CVS directory, or rename the");
            error (0, 0, "directory if it is intended to store something");
            error (0, 0, "besides CVS administrative files.");
            error (1, 0, "*PANIC* administration files missing!");
+           /* NOT REACHED */
        }
 
-       error (1, save_errno, "cannot open `%s'", tmp);
+       error (1, save_errno, "cannot open %s", quote (file));
+       /* NOT REACHED */
     }
 
     if (getline (&repos, &repos_allocated, fpin) < 0)
     {
-       /* FIXME: should be checking for end of file separately.  */
-       error (0, 0, "in directory `%s':", xupdate_dir);
-       error (1, errno, "cannot read `%s'", CVSADM_REP);
+       char *file = dir_append (update_dir, CVSADM_REP);
+       if (feof (fpin))
+           error (1, 0, "unexpected EOF reading %s", quote (file));
+       else
+           error (1, errno, "cannot read %s", quote (file));
+       /* NOT REACHED */
     }
     if (fclose (fpin) < 0)
-       error (0, errno, "cannot close `%s'", tmp);
+       error (0, errno, "cannot close %s", quote (tmp));
     free (tmp);
 
-    if ((cp = strrchr (repos, '\n')) != NULL)
+    if (cp = strrchr (repos, '\n'))
        *cp = '\0';                     /* strip the newline */
 
     /* If this is a relative repository pathname, turn it into an absolute
      * one by tacking on the current root.  There is no need to grab it from
      * the CVS/Root file via the Name_Root() function because by the time
-     * this function is called, we the contents of CVS/Root have already been
+     * this function is called, the contents of CVS/Root have already been
      * compared to original_root and found to match.
      */
     if (!ISABSOLUTE (repos))
     {
        char *newrepos;
-
-       if (current_parsed_root == NULL)
-       {
-           error (0, 0, "in directory `%s:", xupdate_dir);
-           error (0, 0, "must set the CVSROOT environment variable\n");
-           error (0, 0, "or specify the '-d' option to `%s'.", program_name);
-           error (1, 0, "invalid repository setting");
-       }
+       assert (current_parsed_root);
        if (pathname_levels (repos) > 0)
-       {
-           error (0, 0, "in directory `%s':", xupdate_dir);
-           error (0, 0, "`..'-relative repositories are not supported.");
-           error (1, 0, "invalid source repository");
-       }
-       newrepos = Xasprintf ("%s/%s", original_parsed_root->directory, repos);
+           error (1, 0,
+"unsupported %s-relative repository specification found in %s",
+                  quote_n (0, ".."),
+                  quote_n (1, dir_append (update_dir, CVSADM_REP)));
+
+       newrepos = dir_append (original_parsed_root->directory, repos);
        free (repos);
        repos = newrepos;
     }

Index: sanity.sh
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/sanity.sh,v
retrieving revision 1.1209
retrieving revision 1.1210
diff -u -b -r1.1209 -r1.1210
--- sanity.sh   20 Sep 2008 00:03:14 -0000      1.1209
+++ sanity.sh   22 Sep 2008 18:01:01 -0000      1.1210
@@ -12801,10 +12801,12 @@
 ${SPROG} remove: use \`${SPROG} commit' to remove this file permanently"
 
          if $remote; then
-           # Haven't investigated this one.
+           # FIXCVS
+           # This one is beacause add always assumes the current directory has
+           # a valid CVS/Repository file in it in order to send the root
+           # repository line.  Should be an easy fix.
            dotest_fail conflicts2-142b8r "$testcvs add first-dir/a" \
-"${CPROG} add: in directory \`\.':
-${CPROG} \[add aborted\]: there is no version here; do \`${CPROG} checkout' 
first"
+"$CPROG \[add aborted\]: admin directory \`CVS' is missing; do \`$CPROG 
checkout' first"
            cd first-dir
          else
            dotest conflicts2-142b8 "${testcvs} add first-dir/a" \
@@ -17424,9 +17426,8 @@
          # message (e.g. the one from local CVS).  But at least it is an
          # error message.
          dotest_fail errmsg2-16 "$testcvs add bogus-dir/file16" \
-"$SPROG add: in directory \`bogus-dir':
-$SPROG \[add aborted\]: there is no version here; do \`$SPROG checkout' first" 
\
-"$CPROG \[add aborted\]: no repository"
+"$SPROG \[add aborted\]: admin directory \`bogus-dir/CVS' is missing; do 
\`$SPROG checkout' first" \
+"$SPROG \[add aborted\]: no repository"
          rm -r bogus-dir
 
          # One error condition we don't test for is trying to add a file
@@ -17462,13 +17463,12 @@
          mkdir errmsg3
          cd errmsg3
          mkdir CVS
-         dotest_fail errmsg3-1 "${testcvs} -q up" \
-"${CPROG} update: in directory \`.':
-${CPROG} update: CVS directory found without administrative files\.
-${CPROG} update: Use CVS to create the CVS directory, or rename the
-${CPROG} update: directory if it is intended to store something
-${CPROG} update: besides CVS administrative files\.
-${CPROG} \[update aborted\]: \*PANIC\* administration files missing!"
+         dotest_fail errmsg3-1 "$testcvs -q up" \
+"$CPROG update: admin directory \`CVS' found without administrative files\.
+$CPROG update: Use CVS to create the CVS directory, or rename the
+$CPROG update: directory if it is intended to store something
+$CPROG update: besides CVS administrative files\.
+$CPROG \[update aborted\]: \*PANIC\* administration files missing!"
 
          dokeep
          cd ..




reply via email to

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