bug-cvs
[Top][All Lists]
Advanced

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

[PATCH] CVSREADONLY feature


From: Mark D. Baushke
Subject: [PATCH] CVSREADONLY feature
Date: Wed, 05 Mar 2003 12:54:16 -0800

Hi Folks,

The following patch implements the CVSREADSFS feature in FreeBSD cvs
(the patch does not include the ChangeLog entries yet).

The primary intent of this feature is to be able to do a cvs checkout of
a cvs repository that has been written to a CD-ROM or is available via a
read-only filesystem (possibly even over NFS).

It should be noted that if the environment variable or command-line
switch are used in client/server mode, they are silently ignored by
the FreeBSD cvs.

I suspect that that silently ignoring it when used with remote
repositories may not be desirable. So, I added something to main.c to
not allow that switch to be used in when the repository is remote.

            if (current_parsed_root != NULL && current_parsed_root->isremote)
            {
+               if (readonlyfs)
+                   error (1, 0, "Read-only repository feature unavailable");
+
                /* Create a new list for directory names that we've
                   sent to the server. */
                if (dirs_sent_to_server != NULL)
                    dellist (&dirs_sent_to_server);
                dirs_sent_to_server = getlist ();
            }


However, I am not sure it is the right thing to do.

Comments?

        Thanks,
        -- Mark

Log entry:

* Implement CVSREADONLYFS and -R command-line switch as in FreeBSD cvs.

Index: doc/cvs.texinfo
===================================================================
RCS file: /cvs/ccvs/doc/cvs.texinfo,v
retrieving revision 1.557
diff -u -p -r1.557 cvs.texinfo
--- doc/cvs.texinfo     4 Mar 2003 22:56:19 -0000       1.557
+++ doc/cvs.texinfo     5 Mar 2003 20:53:14 -0000
@@ -7880,6 +7880,16 @@ a command name, @samp{cvs -H} displays o
 Do not log the @samp{cvs_command} in the command history (but execute it
 anyway).  @xref{history}, for information on command history.
 
address@hidden Read-only repository mode
address@hidden -R
+Turns on read-only repository mode.  This allows one to check out from a
+read-only repository, such as within an anoncvs server, or from a CDROM
+repository.
+
+Same effect as if the @code{CVSREADONLYFS} environment
+variable is set. Using @samp{-R} can also considerably
+speed up checkout's over NFS.
+
 @cindex Read-only mode
 @item -n
 Do not change any files.  Attempt to execute the
@@ -13585,6 +13595,16 @@ If this is set, @code{checkout} and @cod
 try hard to make the files in your working directory
 read-only.  When this is not set, the default behavior
 is to permit modification of your working files.
+
address@hidden CVSREADONLYFS, environment variable
address@hidden $CVSREADONLYFS
+Turns on read-only repository mode. This allows one to
+check out from a read-only repository, such as within
+an anoncvs server, or from a CDROM repository.
+
+It has the same effect as if the @samp{-R} command-line
+option is used. This can also allow the use of
+read-only NFS repositories.
 
 @item $CVSUMASK
 Controls permissions of files in the repository.  See
Index: doc/stamp-vti
===================================================================
RCS file: /cvs/ccvs/doc/stamp-vti,v
retrieving revision 1.27
diff -u -p -r1.27 stamp-vti
--- doc/stamp-vti       27 Feb 2003 16:51:22 -0000      1.27
+++ doc/stamp-vti       5 Mar 2003 20:53:14 -0000
@@ -1,4 +1,4 @@
address@hidden UPDATED 27 February 2003
address@hidden UPDATED-MONTH February 2003
address@hidden UPDATED 4 March 2003
address@hidden UPDATED-MONTH March 2003
 @set EDITION 1.12.0.1
 @set VERSION 1.12.0.1
Index: doc/version.texi
===================================================================
RCS file: /cvs/ccvs/doc/version.texi,v
retrieving revision 1.28
diff -u -p -r1.28 version.texi
--- doc/version.texi    27 Feb 2003 16:51:22 -0000      1.28
+++ doc/version.texi    5 Mar 2003 20:53:14 -0000
@@ -1,4 +1,4 @@
address@hidden UPDATED 27 February 2003
address@hidden UPDATED-MONTH February 2003
address@hidden UPDATED 4 March 2003
address@hidden UPDATED-MONTH March 2003
 @set EDITION 1.12.0.1
 @set VERSION 1.12.0.1
Index: man/cvs.1
===================================================================
RCS file: /cvs/ccvs/man/cvs.1,v
retrieving revision 1.32
diff -u -p -r1.32 cvs.1
--- man/cvs.1   4 Mar 2003 22:56:19 -0000       1.32
+++ man/cvs.1   5 Mar 2003 20:53:14 -0000
@@ -235,6 +235,16 @@ Same effect as if the
 .SM CVSREAD
 environment variable is set.
 .TP
+.B \-R
+Turns on read-only repository mode.  This allows one to check out from a
+read-only repository, such as within an anoncvs server, or from a CDROM
+repository.
+Same effect as if the
+.SM CVSREADONLYFS
+environment variable is set.  Using
+.B \-R
+can also considerably speed up checkout's over NFS.
+.TP
 .B \-v [ --version ]
 Displays version and copyright information for
 .BR cvs .
@@ -2051,6 +2061,13 @@ and
 will try hard to make the files in your working directory read-only.
 When this is not set, the default behavior is to permit modification
 of your working files.
+.TP
+.SM CVSREADONLYFS
+If this is set, the
+.B \-R
+option is assumed, and
+.B cvs
+operates in read-only repository mode.
 .TP
 .SM RCSBIN
 Specifies the full pathname where to find
Index: src/cvs.h
===================================================================
RCS file: /cvs/ccvs/src/cvs.h,v
retrieving revision 1.241
diff -u -p -r1.241 cvs.h
--- src/cvs.h   25 Feb 2003 22:02:13 -0000      1.241
+++ src/cvs.h   5 Mar 2003 20:53:14 -0000
@@ -313,6 +313,8 @@ extern int errno;
 #define        CVSREAD_ENV     "CVSREAD"       /* make files read-only */
 #define        CVSREAD_DFLT    0               /* writable files by default */
 
+#define        CVSREADONLYFS_ENV "CVSREADONLYFS" /* repository is read-only */
+
 #define        TMPDIR_ENV      "TMPDIR"        /* Temporary directory */
 
 #define        EDITOR1_ENV     "CVSEDITOR"     /* which editor to use */
@@ -440,6 +442,7 @@ extern int safe_location PROTO ((char *)
 
 extern int trace;              /* Show all commands */
 extern int noexec;             /* Don't modify disk anywhere */
+extern int readonlyfs;         /* fail on all write locks; succeed all read 
locks */
 extern int logoff;             /* Don't write history entry */
 
 extern int top_level_admin;
Index: src/lock.c
===================================================================
RCS file: /cvs/ccvs/src/lock.c,v
retrieving revision 1.62
diff -u -p -r1.62 lock.c
--- src/lock.c  28 Feb 2003 17:59:14 -0000      1.62
+++ src/lock.c  5 Mar 2003 20:53:14 -0000
@@ -410,7 +410,7 @@ Reader_Lock (xrepository)
 
     TRACE (1, "Reader_Lock(%s)", xrepository);
 
-    if (noexec)
+    if (noexec || readonlyfs)
        return (0);
 
     /* we only do one directory at a time for read locks! */
@@ -484,6 +484,11 @@ Writer_Lock (list)
 
     if (noexec)
        return (0);
+
+    if (readonlyfs) {
+       error (0, 0, "write lock failed - read-only repository");
+       return (1);
+    }
 
     /* We only know how to do one list at a time */
     if (locklist != (List *) NULL)
Index: src/main.c
===================================================================
RCS file: /cvs/ccvs/src/main.c,v
retrieving revision 1.175
diff -u -p -r1.175 main.c
--- src/main.c  13 Feb 2003 01:30:19 -0000      1.175
+++ src/main.c  5 Mar 2003 20:53:14 -0000
@@ -41,6 +41,7 @@ int really_quiet = 0;
 int quiet = 0;
 int trace = 0;
 int noexec = 0;
+int readonlyfs = 0;
 int logoff = 0;
 
 /* Set if we should be writing CVSADM directories at top level.  At
@@ -251,6 +252,7 @@ static const char *const opt_usage[] =
     "    -n           Do not execute anything that will change the disk.\n",
     "    -t           Show trace of program execution (repeat for more\n",
     "                 verbosity) -- try with -n.\n",
+    "    -R           Assume repository is read-only, such as CDROM\n",
     "    -v           CVS version and copyright.\n",
     "    -T tmpdir    Use 'tmpdir' for temporary files.\n",
     "    -e editor    Use 'editor' for editing log information.\n",
@@ -408,7 +410,7 @@ main (argc, argv)
     int help = 0;              /* Has the user asked for help?  This
                                   lets us support the `cvs -H cmd'
                                   convention to give help for cmd. */
-    static const char short_options[] = "+Qqrwtnlvb:T:e:d:Hfz:s:xa";
+    static const char short_options[] = "+QqrwtnRlvb:T:e:d:Hfz:s:xa";
     static struct option long_options[] =
     {
         {"help", 0, NULL, 'H'},
@@ -471,6 +473,10 @@ main (argc, argv)
     }
     if (getenv (CVSREAD_ENV) != NULL)
        cvswrite = 0;
+    if (getenv (CVSREADONLYFS_ENV) != NULL) {
+       readonlyfs = 1;
+       logoff = 1;
+    }
 
     /* Set this to 0 to force getopt initialization.  getopt() sets
        this to 1 internally.  */
@@ -536,6 +542,10 @@ main (argc, argv)
            case 't':
                trace++;
                break;
+           case 'R':
+               readonlyfs = -1;
+               logoff = 1;
+               break;
            case 'n':
                noexec = 1;
            case 'l':                   /* Fall through */
@@ -979,6 +989,9 @@ Copyright (c) 1989-2003 Brian Berliner, 
             */
            if (current_parsed_root != NULL && current_parsed_root->isremote)
            {
+               if (readonlyfs)
+                   error (1, 0, "Read-only repository feature unavailable");
+
                /* Create a new list for directory names that we've
                   sent to the server. */
                if (dirs_sent_to_server != NULL)
Index: src/sanity.sh
===================================================================
RCS file: /cvs/ccvs/src/sanity.sh,v
retrieving revision 1.765
diff -u -p -r1.765 sanity.sh
--- src/sanity.sh       4 Mar 2003 23:42:34 -0000       1.765
+++ src/sanity.sh       5 Mar 2003 20:53:15 -0000
@@ -3733,6 +3733,40 @@ done"
          ;;
 
 
+       commit-readonlyfs)
+         mkdir 1; cd 1
+         module=x
+         : > junk
+         dotest commit-readonlyfs-1 "${testcvs} -Q import -m . $module X Y" ''
+         if $remote; then
+           dotest_fail commit-readonlyfs-2r1 "${testcvs} -Q -R co $module" \
+"${PROG} \[checkout aborted\]: Read-only repository feature unavailable"
+           dotest commit-readonlyfs-2r2 "${testcvs} -Q co $module" ''
+          else
+           dotest commit-readonlyfs-2 "${testcvs} -Q -R co $module" ''
+          fi
+         cd $module
+         echo test > junk
+         if $remote; then
+           dotest_fail commit-readonlyfs-3r "${testcvs} -Q -R ci -m. junk" \
+"${PROG} \[commit aborted\]: Read-only repository feature unavailable"
+         else
+           dotest_fail commit-readonlyfs-3 "${testcvs} -Q -R ci -m. junk" \
+"${PROG} [a-z]*: write lock failed - read-only repository
+${PROG} \[commit aborted\]: lock failed - giving up"
+          fi
+
+         if $keep; then
+           echo Keeping ${TESTDIR} and exiting due to --keep
+           exit 0
+         fi
+
+         cd ../..
+         rm -rf 1
+         rm -rf ${CVSROOT_DIRNAME}/$module
+         ;;
+
+
        rdiff)
                # Test rdiff
                # XXX for now this is just the most essential test...




reply via email to

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