tags:

views:

8530

answers:

6

I'm not quite sure how this happened, but somehow a completely empty hierarchy of directories has ended up in my repository:

com/
com/companyname/
com/companyname/blah/
com/sun/
com/sun/java/
com/sun/java/jax_rpc_ri/

I think what happened was that these directories did have files in them, but then a developer realized he/she shouldn't have checked them in in the first place since these are by-products of the build process, so he/she removed the files but somehow the empty directories are left in the repository as ancient relics.

How can I remove this from CVS? The only results I seem to be able to find on google say that there shouldn't be a need to remove empty directories as CVS won't keep them around in the first place, and that the -P (prune) options to cvs update should remove them from the working directory - which is zero help if you actually have empty directories in your repository.

A cvs remove and cvs commit doesn't seem to take care of this situation:

$ cvs remove -Rf com
cvs remove: Removing com
cvs remove: Removing com/companyname
cvs remove: Removing com/companyname/blah
cvs remove: Removing com/sun
cvs remove: Removing com/sun/java
cvs remove: Removing com/sun/java/jax_rpc_ri
$ cvs commit com
cvs commit: Examining com
cvs commit: Examining com/companyname
cvs commit: Examining com/companyname/blah
cvs commit: Examining com/sun
cvs commit: Examining com/sun/java
cvs commit: Examining com/sun/java/jax_rpc_ri
$ ls -l com
total 24
drwxrwxr-x  2 matt matt 4096 Oct 15 14:38 CVS
drwxrwxr-x  9 matt matt 4096 Oct 15 14:38 companyname
drwxrwxr-x  4 matt matt 4096 Oct 15 14:38 sun

It's still there!

Does SVN have this weird behavior too?

+7  A: 

AFAIK CVS protocol does not allow to remove directories. You should go the server console and remove them from the real physical repository.


http://www.network-theory.co.uk/docs/cvsmanual/Removingdirectories.html

You don't remove the directory itself; there is no way to do that.

smink
Warning! It is necessary to go to the real, physical, repository because once CVS loses a directory, it can never get it back again. CVS stores files that have been erased in special folders called `Attic`. If you erase the `Attic` then those files are lost forever.
Kevin Panko
+6  A: 

CVS checkout and update will always check out empty directories; that's just the way CVS is built. Do an update with "-P" -- "prune" -- to remove empty directories:

cvs update -dP

(Adding "-d" will update new directories that have appeared since your last update; otherwise, CVS will ignore them.)

Commodore Jaeger
This only removes the empty directories from the working copy - I want to remove them from the repository.
matt b
+1  A: 

cvs tends to work on a two phase approach regarding directories that's why there is a -P option for many cvs commands to "Prune empty directories".

When this has happened, e.g. want to rename a directory I've just added, I delete the directory, delete the entry for the directory in the CVS/Entries file, it'll be a line perpended with a "D".

Job done.

If I've committed, I make sure my current working area that contains the empty directory/ies is all checked in. Then I blow away the part of the work area that I have added the directories to.

For example, in

~/Sandbox/my_project/some_stuff_i_want
~/Sandbox/my_project/empty_dir_1
~/Sandbox/my_project/other_stuff_i_want

I make sure everything is up to date in both directories containing the stuff I want to keep. I then blow away my_project from within my sandbox.

Then I delete the empty directories from the repository itself.

Going back and checking out the same work area, e.g. my_project will give me the work area without the empty dirs.

Or just leave everything as is and use the -P option to get CVS check everything out (or update everything) then prune out the empty dirs.

HTH

cheers,

Rob

Rob Wells
Thanks. This helped me undo damage done by some idjut at work.
Tanktalus
+3  A: 

CVS has a number of design flaws, never being able to get rid of a directory without losing history is one. Difficulty renaming files and directories without losing history is another.

Consider graduating to Subversion. cvs2svn does a very good job converting repositories including all branches and tags. The CVS and SVN command sets are very similar and require minimal adjustment. (And to head off this becoming a "what version control should you use" war) once you're using SVN you can move to any number of more advanced version control systems such as git or SVK.

Schwern
A: 

Just did

  1. rm -rvf /localCopy/project/emptyDirectory
  2. edit /localCopy/project/CVS/Entries, delete line D/emptyDirectory////, save file
  3. rmdir -v /CVSROOT/project/emptyDirectory

to get rid of emptyDirectory in project. Admit not legit to mess with internal CVS data, but seems to have worked (cvs version 1.12.13).

Ljubomir Josifovski
A: 

Hi

This worked for me. Basically When you do

rmdir -v /CVSROOT/project/emptyDirectory # We are deleting directory from CVS repository directory.

If you have repository unix server login access, you can travel to the path and can delete the directory,or raise the same concern with unix team.

Pramod Jaiswal