I am sending you a patch to CVS that adds support for the '-r' switch to 
the modules files.  This allows the creation of version-specific modules 
that automatically check out the correct version/branch tag.  We have been 
using this patch very successfully for the last two years at Ajuba 
Solutions.  I hope it will prove useful to others.  This patch is the 
smallest change I could think of to add this feature.  It's possibly not 
the most elegant approach, since it involves exporting a previously static 
variable.  However, it does work and is a quite small patch.

I grant permission to distribute this patch under the terms of the GNU 
Public License.

--Scott

? diff/libdiff.plg
? diff/libdiff.mak
? zlib/zlib.plg
? zlib/zlib.mak
Index: NEWS
===================================================================
RCS file: /home2/cvsroot/ccvs/NEWS,v
retrieving revision 1.84
diff -c -r1.84 NEWS
*** NEWS        2000/10/17 19:11:33     1.84
--- NEWS        2000/10/18 00:49:58
***************
*** 1,5 ****
--- 1,9 ----
  Changes since 1.11:
  
+ * The 'modules' file now supports the '-r' switch.  This allows the creation of
+ version specific module names that automatically check out the proper version
+ or branch tag.
+ 
  * The ~/.cvspass file has a slightly modified format.  Now two slightly
  different CVSROOTs which represent the same repository and user name no longer
  require separate calls to 'cvs login' to use.  The new code should be backwards
Index: src/ChangeLog
===================================================================
RCS file: /home2/cvsroot/ccvs/src/ChangeLog,v
retrieving revision 1.1974
diff -c -r1.1974 ChangeLog
*** src/ChangeLog       2000/10/17 18:42:28     1.1974
--- src/ChangeLog       2000/10/18 00:49:59
***************
*** 1,3 ****
--- 1,10 ----
+ 2000-10-17  Scott Stanton  <[EMAIL PROTECTED]>
+ 
+       * checkout.c (checkout): Added support for the '-r' option to the
+       modules file.
+       * modules.c (do_module): Made the 'tag' variable non-static so it
+       can be used from the checkout file.
+ 
  2000-10-17  Derek Price  <[EMAIL PROTECTED]>
  
        * cvs.h: added CVSroot_password variable. Provided prototypes for
Index: src/checkout.c
===================================================================
RCS file: /home2/cvsroot/ccvs/src/checkout.c,v
retrieving revision 1.91
diff -c -r1.91 checkout.c
*** src/checkout.c      2000/09/27 14:33:15     1.91
--- src/checkout.c      2000/10/18 00:50:03
***************
*** 86,92 ****
  static int pipeout;
  static int aflag;
  static char *options = NULL;
! static char *tag = NULL;
  static int tag_validated = 0;
  static char *date = NULL;
  static char *join_rev1 = NULL;
--- 86,92 ----
  static int pipeout;
  static int aflag;
  static char *options = NULL;
! char *tag = NULL;
  static int tag_validated = 0;
  static char *date = NULL;
  static char *join_rev1 = NULL;
Index: src/modules.c
===================================================================
RCS file: /home2/cvsroot/ccvs/src/modules.c,v
retrieving revision 1.60
diff -c -r1.60 modules.c
*** src/modules.c       2000/07/26 19:29:01     1.60
--- src/modules.c       2000/10/18 00:50:03
***************
*** 24,36 ****
  #include "cvs.h"
  #include "savecwd.h"
  
  
  /* Defines related to the syntax of the modules file.  */
  
  /* Options in modules file.  Note that it is OK to use GNU getopt features;
     we already are arranging to make sure we are using the getopt distributed
     with CVS.  */
! #define       CVSMODULE_OPTS  "+ad:i:lo:e:s:t:u:"
  
  /* Special delimiter.  */
  #define CVSMODULE_SPEC        '&'
--- 24,38 ----
  #include "cvs.h"
  #include "savecwd.h"
  
+ extern char *tag;
+ 
  
  /* Defines related to the syntax of the modules file.  */
  
  /* Options in modules file.  Note that it is OK to use GNU getopt features;
     we already are arranging to make sure we are using the getopt distributed
     with CVS.  */
! #define       CVSMODULE_OPTS  "+ad:i:lo:e:r:s:t:u:"
  
  /* Special delimiter.  */
  #define CVSMODULE_SPEC        '&'
***************
*** 132,137 ****
--- 134,141 ----
      char *cp;
      int c, err = 0;
      int nonalias_opt = 0;
+     char *default_tag = NULL;
+     int restore_tag;
  
  #ifdef SERVER_SUPPORT
      int restore_server_dir = 0;
***************
*** 447,452 ****
--- 451,462 ----
                export_prog = xstrdup (optarg);
                nonalias_opt = 1;
                break;
+           case 'r':
+               nonalias_opt = 1;
+               if (default_tag)
+                   free (default_tag);
+               default_tag = xstrdup (optarg);
+               break;
            case 't':
                if (tag_prog)
                    free (tag_prog);
***************
*** 516,521 ****
--- 526,541 ----
        goto do_module_return;
      }
  
+     if (default_tag && !tag)
+     {
+       restore_tag = 1;
+       tag = default_tag;
+     }
+     else
+     {
+       restore_tag = 0;
+     }
+ 
      /* otherwise, process this module */
      if (modargc > 0)
      {
***************
*** 574,579 ****
--- 594,603 ----
  
    do_special:
  
+     if (restore_tag)
+     {
+       tag = NULL;
+     }
      free_names (&xmodargc, xmodargv);
      xmodargv = NULL;
  

Reply via email to