info-cvs
[Top][All Lists]
Advanced

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

Re: Accessing CVS files during commit (via a script)


From: Mark
Subject: Re: Accessing CVS files during commit (via a script)
Date: Mon, 16 Jul 2001 19:39:12 -0700 (PDT)

Mark, I think you are using cvs in local mode. If you where using it in a
client/server mode, cvs would have the tmp files a location on the server (the
/tmp by default with pserver). Since you are in local mode, there is no need
for cvs to create the tmp files.

you should copy form.html to a tmp directory, run the code format program on
it, and compare it to form.html in the working area, then allow or deny commit.

Mark

--- Mark McDonald <address@hidden> wrote:
> Output from a trigger script:
> 
> #!/usr/bin/perl
> 
> use Cwd;
> use strict;
> 
> use Carp;
> 
> my $pwd = cwd();
> 
> open (F, ">/tmp/junk/test.txt")  or croak ('can not
> open /tmp/junk/test.txt');
> 
> print F "PWD: $pwd\n";
> print F map { "$_\n"} @ARGV;
> print F `ls -Rla`;
> ##########################################
> 
> ## Output of this script:
> 
> 
> PWD: /home/mark/Test/FormProcessor
> /cvsroot/FormProcessor
> form.html
> .:
> total 48
> drwxr-xr-x    4 mark     mark         4096 Jul 16
> 12:36 .
> drwxr-xr-x    3 mark     mark         4096 Jul 13
> 14:28 ..
> drwxr-xr-x    2 mark     mark         4096 Jul 16
> 12:36 CVS
> drwxr-xr-x    3 mark     mark         4096 Jul 13
> 14:28 Data
> -rwx------    1 mark     mark         2866 Jul 16
> 12:36 form.html
> -rwx------    1 mark     mark         2861 Jul 13
> 15:41 form.html~
> -rwx------    1 mark     mark         9403 Mar 17
> 07:45 form_processor.cgi
> -rwx------    1 mark     mark         8196 Mar 17
> 07:45 form_test.html
> 
> ./CVS:
> total 20
> drwxr-xr-x    2 mark     mark         4096 Jul 16
> 12:36 .
> drwxr-xr-x    4 mark     mark         4096 Jul 16
> 12:36 ..
> -rw-r--r--    1 mark     mark          152 Jul 13
> 15:41 Entries
> -rw-r--r--    1 mark     mark           14 Jul 13
> 14:28 Repository
> -rw-r--r--    1 mark     mark            9 Jul 13
> 14:28 Root
> 
> ./Data:
> total 32
> drwxr-xr-x    3 mark     mark         4096 Jul 13
> 14:28 .
> drwxr-xr-x    4 mark     mark         4096 Jul 16
> 12:36 ..
> -rwx------    1 mark     mark           58 Feb 27
> 08:42 .cgi
> -rwx------    1 mark     mark        12288 Feb 27
> 08:42 .form.html.cgi.swp
> drwxr-xr-x    2 mark     mark         4096 Jul 13
> 14:28 CVS
> -rwx------    1 mark     mark          377 Feb 27
> 08:42 form.html
> 
> ./Data/CVS:
> total 20
> drwxr-xr-x    2 mark     mark         4096 Jul 13
> 14:28 .
> drwxr-xr-x    3 mark     mark         4096 Jul 13
> 14:28 ..
> -rw-r--r--    1 mark     mark          144 Jul 13
> 14:28 Entries
> -rw-r--r--    1 mark     mark           19 Jul 13
> 14:28 Repository
> -rw-r--r--    1 mark     mark            9 Jul 13
> 14:28 Root
> 
> --- Mark <address@hidden> wrote:
> > 
> > I just did some testing, and modifying the server
> > tmp copies is a real bad
> > idea, like Dennis said. But it is good that CVS
> > makes the to-be-commited files
> > available (whether or not by design) to the trigger
> > scripts.
> > 
> > CVS doesn't have precommit triggers and I
> > (personally) don't like tools that
> > have client side triggers.
> > 
> > If you are trying to enforce coding syntax/policy,
> > have your trigger do want it
> > needs to do on a copy of the server tmp files, then
> > compare the resultant files
> > the tmp files server will commit. If they are any
> > differences, reject the
> > commit and tell the user to run the beautifier prior
> > to commit.
> > 
> > Mark
> 
> 
> 
> 
> 
> 
> Thanks Mark. Ok, then  _where_ are these tmp files?!!
> I have basically looked all over my system including
> all cvsroot dirs and the current working dir that the
> trigger script runs.
> 
> I wrote a quick program to do what you said and
> printed above...
> 
> Thanks in advance.
> 
> -Mark McDonald
> 
> > 
> > --- Dennis Jones <address@hidden> wrote:
> > > Mark,
> > > 
> > > Is this really a good idea?  If you do what you
> > are proposing, after you
> > > commit a file, changes will be made to the file
> > (unbeknownst to you) and I
> > > suspect your local copy will immediately be out of
> > date, even though you
> > > just committed it!  So, a question I have is, will
> > CVS *know* that the file
> > > is out of date?  I don't know how CVS works in
> > this regard...does it get a
> > > copy of the file from the repository immediately
> > following a commit?
> > > Perhaps a CVS expert can shed some light on this
> > question.
> > > 
> > > CVS must do *something* at this point though,
> > because it has to modify any
> > > keywords you have in your file (such as $Id) after
> > the commit, but I suspect
> > > that they are modified directly by the client.  If
> > this is the case, then
> > > you will almost surely have trouble with files
> > being out of date and CVS not
> > > knowing that this is the case.  It is also
> > possible that an update might not
> > > even help -- if CVS thinks the file is already
> > updated!
> > > 
> > > So, my next question is, why not run the code
> > through the beautifier PRIOR
> > > to the commit?  Then you will be sure your files
> > are up to date after the
> > > commit, and anyone else that checks out (or
> > updates) the file will get the
> > > beautified copy.
> > > 
> > > - Dennis
> > > 
> > > ----- Original Message -----
> > > From: "Mark McDonald" <address@hidden>
> > > To: "Mark" <address@hidden>; <address@hidden>
> > > Sent: Monday, July 16, 2001 8:39 AM
> > > Subject: Re: Accessing CVS files during commit
> > (via a script)
> > > 
> > > 
> > > > Hi Mark,
> > > >
> > > > Thanks for the response. I know how to get the
> > > > variables though, what I am trying to do is
> > actually
> > > > open up the files that are being committed.
> > > >
> > > >  So for example, suppose you wanted to run a
> > code
> > > > beautifier on the script/file being committed
> > within
> > > > cvs. You would then need access to the incoming
> > file
> > > > that cvs has just received.
> > > >
> > > > I guess what I am asking is if this is possible.
> > The
> > > > 'Open Source Development Book with CVS' claims
> > that
> > > > you can do this --but gives no examples as to
> > how to
> > > > do it.
> > > >
> > > > Any help is totally appreciated!
> > > >
> > > > -Mark McDonald
> > > >
> > > >
> > > > # perl this_script  /cvsroot/mod_perl_config
> > > > startup.perl
> > > > #                            |                  
> > |
> > > > #                      the CVSROOT/module     
> > the
> > > > modified file
> > > > #
> > > >
> > > > # perl this_script
> > > > /cvsroot/mod_perl_config/db_connections
> > > > mikey.connection web_dev.connection
> > > > #                             |
> > > >           |                  |
> > > > #                         the module/sub-dir
> > > >        mod file 1         mod file 2
> > > >
> > > >
> > > > --- Mark <address@hidden> wrote:
> > > > >
> > > > > Ask CVS....
> > > > >
> > > > > create a trigger script to ask questions and
> > find
> > > > > out the trigger's runtime
> > > > > environemnt...
> > > > >
> > > > > things to include might be...
> > > > >
> > > > > print "@ARGV";
> > > > > print "$0,$1,$2.....";
> > > > > pwd;
> > > > > ls -Rla;
> > > > > env;
> > > > >
> > > > > that's how I found out (with pserver anyhow)
> > > > >
> > > > > Mark
> > > > >
> > > > > --- Mark McDonald <address@hidden>
> > wrote:
> > > > > > Does anyone know how this works?!
> > > > > >
> > > > > >
> > > > > > > I am using the CVS Open Source Development
> > book
> > > > > as a
> > > > > > reference to make a
> > > > > > > script that will run upon a cvs commit.
> > > > > Basically
> > > > > > what
> > > > > > > I am trying to do is open up the file that
> > is
> > > > > being
> > > > > > > committed to a repository.
> > > > > > >
> > > > > > > On page 132 of the CVS book (in the top
> > note
> > > > > > section)
> > > > > > > this book states that '
> > > > > >
> > > > > >   the file names passed to the program
> > > > > > > do not refer to the RCS files --they point
> > to
> > > > > normal
> > > > > > > files, whose contents are exactly the same
> > as
> > > > > the
> > > > > > > working-copy files being committed. The
> > only
> > > > > unusual
> > > > > > > aspect is that CVS has them temporarily
> > places
> > > > > > inside
> > > > > > > the repository, so they'll be available to
> > the
> > > > > > > programs running on the machine where the
> > > > > repository
> > > > > > > is located.'
> > > > > > >
> > > > > > >
> > > > > > > I have basically tried everything to
> > locate
> > > > > these
> > > > > > > files so I can do things with them. In
> > this case
> > > > > I
> > > > > > am
> > > > > > > trying to copy the contents to webservers
> > on
> > > > > this
> > > > > > and
> > > > > > > other networks.
> > > > > > >
> > > > > > > I have check the news groups and CVS's
> > homepage
> > > > > > > in search of this info. Perhaps you could
> > give
> > > > > me a
> > > > > > > tip!
> > > > > > >
> > 
> === message truncated ===
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
> 
> _______________________________________________
> Info-cvs mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/info-cvs


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



reply via email to

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