[Top][All Lists]

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

RE: cvs remove and pre-commit check

From: Lakshman Srilakshmanan
Subject: RE: cvs remove and pre-commit check
Date: Thu, 17 Nov 2005 12:06:29 +1100

HI Mark,

Thank you very much for your help. I have fixed the problem.

Just on another note what is your view on Subversion. 
I have been requested to investigate the possibility of migration to
Subversion. I am particularly interested in the branching capability in
Subversion. I am led to believe that it works similar to ClearCase.

Thanks again.


-----Original Message-----
From: Mark E. Hamilton [mailto:address@hidden 
Sent: Thursday, 17 November 2005 8:10 AM
To: Lakshman Srilakshmanan
Cc: address@hidden
Subject: Re: cvs remove and pre-commit check

Lakshman Srilakshmanan wrote:
> Hi All,

I'm presuming that you are using 1.11.x. The following may apply to 
1.12.x, but I don't know.

First, read this:

> I have a pre-commit check as follows. It checks to ensure that the cvs
> tags Author, Revision and Header are present in the file.

No, it doesn't

> #!/bin/sh
> filename=$*
> dirName=$2
> Author=`grep '\$Author' $filename`
> if [ -z "$Author" ] ; then
>     echo "Author does not Exists"
>     exit 1
> fi
<irrelevant commands removed from sample script>

This isn't going to work. According the man page, the parameters passed 
to the command invoked by commitinfo are any parameters you put on the 
command line, followed by the repository directory and *all* the file 
names. Assuming you don't pass any other parameters to your script from 
your commitinfo file, your script's parameters will be

dir f1 {f2 ...}

So, what you should be doing is something like this:


for filename in $*
     check file $filename

> It works fine for new files and changes. But when I commit after a
> remove" I get the following error
> grep: sgs13.txt: No such file or directory

> I understand, that since the file does not exist, grep can't find it. 
> But $* contains the following.
> /cvs/sgs/src/conf sgs13.txt               Note : /cvs ==> is my "cvs
> server root".
> Therefore non of my greps should have worked as the file will be
> sgs13.txt,v under /cvs and 
> would not exist under the repository anyway (for new files).

Your $filename variable value is incorrect. As you point out $* contains

*the directory and the file name(s)*, so that's what is in $filename. 
So, your grep looks like this:

grep '\$Author' /cvs/sgs/src/conf sgs13.txt

This will fail to find $Author in the directory (obviously) but it may 
find it in sgs13.txt, and so assign it to the variable.

For removed files, according to the manual when a file is being removed 
it will not exist in the current directory. So, you can't grep it. You 
should test it for existance before grep'ing it.

Also, since there will be more than one file on the command line you 
must have a file loop as I said above. So combining the file loop and an

existance test you would need:

for filename in $*
     test ! -e $filename && continue
     egrep >/dev/null 2>&1 'blah' $filename || { echo "message" ; exit 1
; }

> Q1. how does cvs know about my file when I am working from windows
> client and the cvs server in on Linux.
> Q2. Why does it work for new files when the directory is /cvs. New
> will not exist in the repository

New and modified files are copied to a temp directory on the server. 
With a local repository they exist in your working directory.
Removed files are not copied to the server, and they do not exist in 
your working directory.

> Q3. Any workaround ?

You need to correct your script.

Mark E. Hamilton
Orion International Technologies, Inc.
Sandia National Laboratory, NM.

reply via email to

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