Remove empty directory from CVS?
Asked Answered
L

7

37

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?

Lubet answered 15/10, 2008 at 14:45 Comment(0)
V
41

AFAIK the CVS protocol does not allow to remove directories. You should go to 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.

Vermilion answered 15/10, 2008 at 14:54 Comment(2)
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.Strohl
Always think twice before you do something like this, but I don't see any problem it: ssh cvsserver:/cvsroot 'tar cvf com.tar com'; scp cvsserver:/cvsroot/com.tar .; cvs add com.tar; cvs ci com.tar; cvs rm -f com.tar; ssh cvsserver:/cvsroot 'rm -rf com.tar com'Eblis
S
22

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.)

Schuh answered 15/10, 2008 at 14:55 Comment(1)
This only removes the empty directories from the working copy - I want to remove them from the repository.Lubet
B
8

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).

Bois answered 4/11, 2009 at 14:3 Comment(0)
H
5

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.

Heteroclite answered 15/10, 2008 at 15:25 Comment(0)
M
4

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.

Mickimickie answered 8/10, 2010 at 12:47 Comment(0)
A
1

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 prepended 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

Ashleyashli answered 15/10, 2008 at 15:7 Comment(1)
Thanks. This helped me undo damage done by some idjut at work.Charlot
G
1

You cannot delete directory from your workspace , you need to delete it from going to server where actual repository is kept. but you can delete files from the directory with cvs remove command.

Genitals answered 27/1, 2014 at 10:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.