Discussion:
How to detect missing CVS directories
Arnon Weinberg
2012-02-26 03:36:20 UTC
Permalink
This problem seems like it should be common, but I haven't found it
posted anywhere.

Developers may accidentally delete a CVS working directory (ie, the one
with the Entries, Repositories, Root files), and not notice that they
have done so. The cvs command just ignores those directories from then
on, so they don't get updated. When checking out / updating a large
tree, developers may not notice that this directory is then skipped.
cd ~/directory/pwd
mv CVS CVS.bak
cvs checkout -A -d ~/directory module
...
? /home/user/directory/pwd
...

Running cvs checkout (or cvs update) without errors or change flags
generally is assumed to mean that the tree is now up to date. However,
in this case, the directory is just skipped (cvs treats it like any file
it doesn't recognize, even though it is in the repository), and the tree
is not sync'ed.

1) How can missing CVS directories be detected?
2) How can they be restored / regenerated?



Arnon Weinberg
www.back2front.ca
Arthur Barrett
2012-02-26 14:16:29 UTC
Permalink
Hi Arnon,

I find the whole 'CVS' directory thing annoying. One day I'll make an
option to store it with a different name, or store it in a different
place - but of course that'll ruin backwards compatibility. One reason
why we have the EntriesParser API in CVSNT - to try and get 3rd parties
to use an API to get to the CVS directory rather than 'assume' it's
'just there'.

Enough of my rant.

Change Management is a process. You need to train your team in how the
tools work, and to follow the process. Then you need to audit their use
of the tools and process.

Ie: this isn't your problem - make it theirs. They wont accidentally
delete a CVS directory, if they are required to checkin code once a day
and you are auditing the checkin logs (a quick check through the commit
e-mails once or twice a day). Make it simple - no commits, poor
comments, etc: no approval of timesheet.

If the developer accidentally deletes all of their code, how do they fix
that? There is your answer to how to restore the missing 'CVS'
directories. Ie:
* checkout the tree again, or
* restore from backup

But if you make this your problem to fix, you'll never hear the end of
it. Compliance with company procedures is the developers
responsibility.

Regards,


Arthur
-----Original Message-----
org] On Behalf Of Arnon Weinberg
Sent: Sunday, 26 February 2012 2:36 PM
Subject: How to detect missing CVS directories
This problem seems like it should be common, but I haven't found it
posted anywhere.
Developers may accidentally delete a CVS working directory
(ie, the one
with the Entries, Repositories, Root files), and not notice that they
have done so. The cvs command just ignores those directories
from then
on, so they don't get updated. When checking out / updating a large
tree, developers may not notice that this directory is then skipped.
cd ~/directory/pwd
mv CVS CVS.bak
cvs checkout -A -d ~/directory module
...
? /home/user/directory/pwd
...
Running cvs checkout (or cvs update) without errors or change flags
generally is assumed to mean that the tree is now up to date.
However,
in this case, the directory is just skipped (cvs treats it
like any file
it doesn't recognize, even though it is in the repository),
and the tree
is not sync'ed.
1) How can missing CVS directories be detected?
2) How can they be restored / regenerated?
Arnon Weinberg
www.back2front.ca
Arnon Weinberg
2012-02-26 19:09:48 UTC
Permalink
Post by Arthur Barrett
They wont accidentally
delete a CVS directory, if they are required to checkin code once a day
//cd//
cvs -n commit
...
cvs commit: in directory directory/pwd
cvs [commit aborted]: there is no version here; do 'cvs checkout' first

does a fine job of detecting missing CVS directories, as desired. Thank
you Arthur.
Post by Arthur Barrett
to restore the missing 'CVS'
* checkout the tree again, or
The error message from cvs commit suggests the same thing, however as
per my earlier example, this doesn't work, unless I'm doing it wrong.
Post by Arthur Barrett
cd ..
mv pwd pwd.bak
/cvs checkout -A -d ~/directory module/
mv pwd/CVS pwd.bak
rm -rf pwd
mv pwd.bak pwd
Let me know if there is a simpler solution that I'm overlooking.


Arnon Weinberg
www.back2front.ca
Jim Hyslop
2012-02-27 02:25:00 UTC
Permalink
//cd// cvs -n commit
I usually use the command "cvs -nq update", which will print a ?
before each file it doesn't know about. The -q option suppresses the
"Processing directory abc" messages, which can hide more important
messages.
One solution I found is to temporarily rename the containing
cd .. mv pwd pwd.bak /cvs checkout -A -d ~/directory module/ mv
pwd/CVS pwd.bak rm -rf pwd mv pwd.bak pwd
That's only part of what you need to do.

When you checkout to the temporary directory, CVS will populate it
with the current versions in the repository, which may not match the
versions that were checked out at the time the CVS directory was blown
away. CVS will indicate that the developer has modified the file
locally. If the developer then checks in the file, then they will in
fact check in an older version of the file, blowing away the more
recent changes.

After you have restored the CVS directory, you will need to execute
'cvs -nq update' to get a list of all files which CVS thinks have been
modified, then compare each of the files against /earlier/ versions in
the repository. For example, if 'cvs status filename' indicates
revision 1.4, you must compare the file against 1.3 (`cvs diff -r1.3
filename`).


Don't just compare it against the previous version, you must go back
several versions to be sure you have the correct version. If the
"modified" version is identical to an earlier version, then you must
use 'cvs update -C filename' to bring it in sync with the repository.
This will discard local changes, and fetch the current version from
the repository.

The tricky part comes in for files that actually were modified
locally, and which also were checked into the repository. For those
files, you will have to use the 'update -C' command, and manually
re-apply the local modifications.

As Arthur suggested, frequent checkins can mitigate these problems,
but you still need to be aware that they can occur. And, of course,
there is no substitute for training the developers to be more careful
and not delete the CVS directory.

- --
Jim Hyslop
Dreampossible: Better software. Simply. http://www.dreampossible.ca
Consulting * Mentoring * Training in
C/C++ * OOD * SW Development & Practices * Version Management

Loading...