bug-cvs
[Top][All Lists]
Advanced

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

[patch] CVSROOT parsing changes


From: Mark D. Baushke
Subject: [patch] CVSROOT parsing changes
Date: Wed, 01 Dec 2004 08:54:12 -0800

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Greetings,

For a time, there has been talk about the desirability to add CVS_RSH
and CVS_SERVER information to the CVSROOT so that different values of
those environment variables may be used with different roots.

Attached is a patch that adds both CVS_RSH and CVS_SERVER to CVSROOT
using the option syntax that was already added to support the proxyhost
and proxyport options.

This patch also allows the methods and option names in CVSROOT to be
case insensitive which is compatible with how CVSNT deals with its
parsing.

Note: CVSNT has two separate syntaxes, the current CVS syntax of
:method;option=value;option2=value2: and a
[method=method,option='value',option2=value2,opt3="val3"] syntax.
However, this patch does not add any quoting to the option values.

What do folks think of this patch? I would like to commit it to the
feature branch (cvs 1.12.x).

        Thanks,
        -- Mark

Index: NEWS
===================================================================
RCS file: /cvs/ccvs/NEWS,v
retrieving revision 1.287
diff -u -p -r1.287 NEWS
- --- NEWS      17 Nov 2004 20:51:52 -0000      1.287
+++ NEWS        1 Dec 2004 16:45:05 -0000
@@ -3,6 +3,12 @@ Changes since 1.12.10:
 
 NEW FEATURES
 
+* CVSROOT methods and option names are now case insensitive
+
+* CVSROOT methods :ext: now support the CVS_SERVER option.
+
+* CVSROOT method :ext: now supports the CVS_RSH option.
+
 * Date handling has been improved slightly.
 
 * Miscellaneous bug fixes.
Index: doc/cvs.texinfo
===================================================================
RCS file: /cvs/ccvs/doc/cvs.texinfo,v
retrieving revision 1.627
diff -u -p -r1.627 cvs.texinfo
- --- doc/cvs.texinfo   29 Nov 2004 18:48:13 -0000      1.627
+++ doc/cvs.texinfo     1 Dec 2004 16:45:06 -0000
@@ -2089,7 +2089,8 @@ methods all accept optional method optio
 :@var{method}[;@var{option}=@var{arg}...]:
 @end example
 
- -Currently, the only two valid connection options are @code{proxy}, which
+Currently, the only two valid connection options for
+all remote @var{method}s are @code{proxy}, which
 takes a hostname as an argument, and @code{proxyport}, which takes a port
 number as an argument.  These options can be used to connect via an HTTP
 tunnel style web proxy.  For example, to connect pserver via a web proxy
@@ -2104,6 +2105,47 @@ the server as noted in the upcoming sect
 gserver and kserver.  The example above would only modify the @var{method}
 portion of the repository name.}
 
+@cindex CVS_RSH option for :ext: method
+@cindex CVS_SERVER option for :ext: method
+There are also two options available for the
+@var{method} @code{ext}, the @var{CVS_RSH} and
+@var{CVS_SERVER} options. The @var{CVS_SERVER} option
+may also be used with the @code{fork} method.
+
+For example, to connect to via the
+@code{/path/to/ssh/command} command, you could choose
+to add the @var{CVS_RSH} option with a method of:
+
+@example
+:ext;CVS_RSH=/path/to/ssh/command:
+@end example
+
+or to specify the name of the remote @code{cvs} command
+as being @code{/path/to/cvs/command} or
+@code{cvs-1.12.11}, you could add the @var{CVS_SERVER}
+option with a method of:
+
+@example
+:ext;CVS_SERVER=/path/to/cvs/command:
+@end example
+
+or
+
+@example
+:ext;CVS_SERVER=cvs-1.12.11:
+@end example
+
+and to combine both of those options, a method of:
+
+@example
+:ext;CVS_RSH=/path/to/ssh/command;CVS_SERVER=/path/to/cvs/command:
+@end example
+
+would work. This means that you would not need to have
+the @code{CVS_SERVER} or @code{CVS_RSH} environment
+variables set. See @ref{Connecting via rsh}, for more details on the
+environment variables.
+
 @cindex CVS_PROXY_PORT
 @var{proxy} must be supplied to connect to a CVS server via a
 proxy server, but @var{proxyport} will default to port 8080 if not supplied.
@@ -2265,10 +2307,11 @@ or @file{.profile}.  Alternately, you ca
 environment variable @code{CVS_SERVER} on the client
 machine to the filename of the server you want to use,
 for example @file{/usr/local/bin/cvs-1.6}.
- -@c FIXME: there should be a way to specify the
- -@c program in CVSROOT, not CVS_SERVER, so that one can use
- -@c different ones for different roots.  e.g. ":server;cvs=cvs-1.6:"
- -@c instead of ":server:".
+For the @code{ext} and @code{fork} methods, you may
+also specify @var{CVS_SERVER} as an otpion in the
+@var{CVSROOT} so that you may use different servers for
+differnt roots. See @ref{Remote repositories} for more
+details.
 
 There is no need to edit @file{inetd.conf} or start a
 @sc{cvs} server daemon.
@@ -2300,10 +2343,13 @@ replacement, the instructions in the res
 section concerning @file{.rhosts} and so on are likely
 to be inapplicable; consult the documentation for your rsh
 replacement.
- -@c FIXME: there should be a way to specify the
- -@c program in CVSROOT, not CVS_RSH, so that one can use
- -@c different ones for different roots.  e.g. ":ext;rsh=remsh:"
- -@c instead of ":ext:".
+
+You may choose to specify the @var{CVS_RSH} option in
+the @var{CVSROOT} to allow you to use different ones
+for different roots. For example, allowing some roots
+to use @var{CVS_RSH=remsh} and some to use
+@var{CVS_RSH=ssh} for the @code{ext} method. See also
+the @ref{Remote repositories} for more details.
 @c See also the comment in src/client.c for rationale
 @c concerning "rsh" being the default and never
 @c "remsh".
@@ -8603,7 +8649,7 @@ and @code{update}.
 @end table
 
 @c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -@include getdate-cvs.texi
+@include getdate.texi
 
 @c - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 @node admin
Index: src/client.c
===================================================================
RCS file: /cvs/ccvs/src/client.c,v
retrieving revision 1.407
diff -u -p -r1.407 client.c
- --- src/client.c      30 Nov 2004 14:43:44 -0000      1.407
+++ src/client.c        1 Dec 2004 16:45:07 -0000
@@ -3730,7 +3730,8 @@ connect_to_forked_server (cvsroot_t *roo
 
      char *command[3];
 
- -    command[0] = getenv ("CVS_SERVER");
+    command[0] = (root->cvs_server != NULL
+                 ? root->cvs_server : getenv ("CVS_SERVER"));
     if (!command[0])
 # ifdef SERVER_SUPPORT
         /* FIXME:
Index: src/root.c
===================================================================
RCS file: /cvs/ccvs/src/root.c,v
retrieving revision 1.98
diff -u -p -r1.98 root.c
- --- src/root.c        19 Nov 2004 22:53:16 -0000      1.98
+++ src/root.c  1 Dec 2004 16:45:07 -0000
@@ -386,6 +386,8 @@ new_cvsroot_t (void)
     newroot->username = NULL;
     newroot->password = NULL;
     newroot->hostname = NULL;
+    newroot->cvs_rsh = NULL;
+    newroot->cvs_server = NULL;
     newroot->port = 0;
     newroot->directory = NULL;
     newroot->proxy_hostname = NULL;
@@ -417,6 +419,10 @@ free_cvsroot_t (cvsroot_t *root)
     }
     if (root->hostname != NULL)
        free (root->hostname);
+    if (root->cvs_rsh != NULL)
+       free (root->cvs_rsh);
+    if (root->cvs_server != NULL)
+       free (root->cvs_server);
     if (root->proxy_hostname != NULL)
        free (root->proxy_hostname);
 #endif /* CLIENT_SUPPORT */
@@ -509,19 +515,19 @@ parse_cvsroot (const char *root_in)
 
        /* Now we have an access method -- see if it's valid. */
 
- -     if (strcmp (method, "local") == 0)
+       if (!strcasecmp (method, "local"))
            newroot->method = local_method;
- -     else if (strcmp (method, "pserver") == 0)
+       else if (!strcasecmp (method, "pserver"))
            newroot->method = pserver_method;
- -     else if (strcmp (method, "kserver") == 0)
+       else if (!strcasecmp (method, "kserver"))
            newroot->method = kserver_method;
- -     else if (strcmp (method, "gserver") == 0)
+       else if (!strcasecmp (method, "gserver"))
            newroot->method = gserver_method;
- -     else if (strcmp (method, "server") == 0)
+       else if (!strcasecmp (method, "server"))
            newroot->method = server_method;
- -     else if (strcmp (method, "ext") == 0)
+       else if (!strcasecmp (method, "ext"))
            newroot->method = ext_method;
- -     else if (strcmp (method, "fork") == 0)
+       else if (!strcasecmp (method, "fork"))
            newroot->method = fork_method;
        else
        {
@@ -542,11 +548,12 @@ parse_cvsroot (const char *root_in)
            }
 
            *q++ = '\0';
- -         if (strcmp (p, "proxy") == 0)
+           TRACE (TRACE_DATA, "CVSROOT option=`%s' value=`%s'", p, q);
+           if (!strcasecmp (p, "proxy"))
            {
                newroot->proxy_hostname = xstrdup (q);
            }
- -         else if (strcmp (p, "proxyport") == 0)
+           else if (!strcasecmp (p, "proxyport"))
            {
                char *r = q;
                if (*r == '-') r++;
@@ -565,6 +572,19 @@ parse_cvsroot (const char *root_in)
 "CVSROOT may only specify a positive, non-zero, integer proxy port (not 
`%s').",
                           q);
            }
+           else if (!strcasecmp (p, "CVS_RSH"))
+           {
+               /* override CVS_RSH environment variable */
+               if (newroot->method == ext_method)
+                   newroot->cvs_rsh = xstrdup (q);
+           }
+           else if (!strcasecmp (p, "CVS_SERVER"))
+           {
+               /* override CVS_SERVER environment variable */
+               if (newroot->method == ext_method
+                   || newroot->method == fork_method)
+                   newroot->cvs_server = xstrdup (q);
+           }
            else
            {
                error (0, 0, "Unknown option (`%s') in CVSROOT.", p);
Index: src/root.h
===================================================================
RCS file: /cvs/ccvs/src/root.h,v
retrieving revision 1.12
diff -u -p -r1.12 root.h
- --- src/root.h        1 Oct 2004 21:34:57 -0000       1.12
+++ src/root.h  1 Dec 2004 16:45:07 -0000
@@ -31,6 +31,9 @@ typedef struct cvsroot_s {
     char *username;            /* The username or NULL if method == local. */
     char *password;            /* The password or NULL if method == local. */
     char *hostname;            /* The hostname or NULL if method == local. */
+    char *cvs_rsh;             /* The $CVS_RSH or NULL if method != ext. */
+    char *cvs_server;          /* The $CVS_SERVER or NULL if
+                                * method != ext and method != fork. */
     int port;                  /* The port or zero if method == local. */
     char *proxy_hostname;      /* The hostname of the proxy server, or NULL
                                 * when method == local or no proxy will be
Index: src/rsh-client.c
===================================================================
RCS file: /cvs/ccvs/src/rsh-client.c,v
retrieving revision 1.9
diff -u -p -r1.9 rsh-client.c
- --- src/rsh-client.c  3 Sep 2004 16:34:15 -0000       1.9
+++ src/rsh-client.c    1 Dec 2004 16:45:07 -0000
@@ -48,8 +48,10 @@ start_rsh_server (cvsroot_t *root, struc
     /* If you're working through firewalls, you can set the
        CVS_RSH environment variable to a script which uses rsh to
        invoke another rsh on a proxy machine.  */
- -    char *cvs_rsh = getenv ("CVS_RSH");
- -    char *cvs_server = getenv ("CVS_SERVER");
+    char *cvs_rsh = (root->cvs_rsh != NULL
+                    ? root->cvs_rsh : getenv ("CVS_RSH"));
+    char *cvs_server = (root->cvs_server != NULL
+                       ? root->cvs_server : getenv ("CVS_SERVER"));
     int i = 0;
     /* This needs to fit "rsh", "-b", "-l", "USER", "host",
        "cmd (w/ args)", and NULL.  We leave some room to grow. */
@@ -128,8 +130,10 @@ start_rsh_server (cvsroot_t *root, struc
     /* If you're working through firewalls, you can set the
        CVS_RSH environment variable to a script which uses rsh to
        invoke another rsh on a proxy machine.  */
- -    char *cvs_rsh = getenv ("CVS_RSH");
- -    char *cvs_server = getenv ("CVS_SERVER");
+    char *cvs_rsh = (root->cvs_rsh != NULL
+                    ? root->cvs_rsh : getenv ("CVS_RSH"));
+    char *cvs_server = (root->cvs_server != NULL
+                       ? root->cvs_server : getenv ("CVS_SERVER"));
     char *command;
     int tofd, fromfd;
     int child_pid;
Index: src/sanity.sh
===================================================================
RCS file: /cvs/ccvs/src/sanity.sh,v
retrieving revision 1.1031
diff -u -p -r1.1031 sanity.sh
- --- src/sanity.sh     30 Nov 2004 14:43:44 -0000      1.1031
+++ src/sanity.sh       1 Dec 2004 16:45:12 -0000
@@ -1573,8 +1573,8 @@ RCSINIT=; export RCSINIT
 if test x"$*" = x; then
        # Basic/miscellaneous functionality
        tests="version basica basicb basicc basic1 deep basic2 ls"
- -     tests="$tests parseroot parseroot2 files spacefiles commit-readonly"
- -     tests="${tests} commit-add-missing"
+       tests="$tests parseroot parseroot2 parseroot3 files spacefiles"
+       tests="${tests} commit-readonly commit-add-missing"
        tests="${tests} status"
        # Branching, tagging, removing, adding, multiple directories
        tests="${tests} rdiff rdiff-short"
@@ -22589,6 +22589,56 @@ EOF
 
 
 
+       parseroot3)
+         # Test some :ext: roots for consistancy.
+         if $remote; then :; else
+           remoteonly parseroot3
+           continue
+         fi
+
+         require_rsh "$CVS_RSH"
+         if test $? -eq 77; then
+           skip parseroot3 "$skipreason"
+           continue
+         fi
+
+         # Test checking out and subsequently updating with some different
+         # CVSROOTs.
+
+         # A standard case, hostname:dirname.
+         mkdir parseroot3; cd parseroot3
+         save_CVSROOT=$CVSROOT
+         save_CVS_RSH=$CVS_RSH
+         save_CVS_SERVER=$CVS_SERVER
+         unset CVS_RSH
+         unset CVS_SERVER
+         
CVSROOT=":ext;CVS_RSH=$save_CVS_RSH;CVS_SERVER=$save_CVS_SERVER:$host:$CVSROOT_DIRNAME"
+         dotest parseroot3-1 "$testcvs -Q co CVSROOT"
+         cd CVSROOT
+         dotest parseroot3-2 "$testcvs -Q up"
+         cd ..
+
+         # A degenerate remote case, just the server name and the directory
+         # name, with no :'s to help parsing.  It can be mistaken for a
+         # relative directory name.
+         rm -r CVSROOT
+         
CVSROOT=":ext;cvs_RSH=$save_CVS_RSH;CVS_Server=$save_CVS_SERVER:$host$CVSROOT_DIRNAME"
+         dotest parseroot3-3 "$testcvs -Q co CVSROOT"
+         cd CVSROOT
+         dotest parseroot3-4 "$testcvs -Q up"
+         cd ..
+
+         dokeep
+         cd ..
+         CVSROOT=$save_CVSROOT
+         CVS_RSH=$save_CVS_RSH
+         CVS_SERVER=$save_CVS_SERVER
+         export CVS_RSH CVS_SERVER
+         rm -r parseroot3
+         ;;
+
+
+
        history)
          # CVSROOT/history tests:
          # history: various "cvs history" invocations
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQFBrfc03x41pRYZE/gRAo4EAJwPSXtYGQWIZ3b91aD2xJo1trNnewCffKiC
5znMUrTdGLPh7azaAIS037g=
=8RXK
-----END PGP SIGNATURE-----




reply via email to

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