info-cvs
[Top][All Lists]
Advanced

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

RE: CVS EXPORT


From: Miller Dale Contractor HQ AFWA
Subject: RE: CVS EXPORT
Date: Tue, 29 Apr 2003 08:56:34 -0500

Samuel Blanchet writes:

> I would like that 'cvs export' never removes empty directories.
> How can I do that ?

Sam,
If you need directories to be present after an export, you can either have a
script create the files or have place holder files in the CVS repository.  I
create a ".keepme" file with "keepme" as its content in the directories of
concern and check the .keepme into the repository.  When a cvs export is
done the directory is created with a hidden file ".keepme"

Dale Miller
Northrop Grumman Information Technology
Bellevue, NE

P.S.

I wrote a "find_empty_directories.plx" program.

Usage:
   find_empty_directories.plx -path=/directory/to/start/at
[-action=list|create]

This program finds all empty directories and identifies where
a ".keepme" should be present so a "cvs export" command will
create the directory.

It also identifies ".keepme" files that exist in non-empty
directories that could be removed.

If -action=create is used a ".keepme" file containing "keepme"
will be created.  -action=create should not be used with a CVS
repository path

The following is my perl program:

#!/usr/local/bin/perl -ws
#
# $Id: find_empty_directories.plx,v 1.2 2000/12/13 18:53:10 miller Exp $
#
# See sub usage for information about this program
#
$path = "" unless defined $path;
$action = "list" unless defined $action;

@ls_result = "";   # used only once

if ($path eq "") {
   &usage("Error: -path must be defined");
   exit 1;
}

if (! -d $path) {
   &usage("Error: -path=$path is not a directory");
   exit 1;
}

if (!(($action eq "list") or ($action eq "create"))) {
   &usage("Error: -action must be list or create");
   exit 1;
}

sub usage {
   print "\nUsage:\n";
   print "   $0 -path=/directory/to/start/at [-action=list|create]\n\n";
   print "This program finds all empty directories and identifies where\n";
   print "a \".keepme\" should be present so a \"cvs export\" command
will\n";
   print "create the directory.\n\n";
   print "It also identifies \".keepme\" files that exist in non-empty\n";
   print "directories that could be removed.\n\n";
   print "If -action=create is used a \".keepme\" file containing
\"keepme\"\n";
   print "will be created.  -action=create should not be used with a CVS\n";
   print "repository path\n\n";
   print "@_\n";
}

@dirlist = `find $path -type d -print`;
#print "@dirlist";

foreach (@dirlist) {
   chomp;
   # -- get a list of all files (including hidden files) but
   # --  do not count . and ..
   # -- if the number of files found is 0 the directory is empty
   $ls_length = grep {!/^\.{1,2}$/} @ls_result = `ls -a $_`;
   if ($ls_length == 0) {   # directory contains only . and ..
      if (! -e "$_/.keepme") {
         if ($action eq "create") {
            print "creating $_/.keepme file\n";
            `echo keepme >$_/.keepme; chmod 444 $_/.keepme`;
         } else {
            print "$_/.keepme should be added\n";
         }
         next;
      }
   }
   if ($ls_length > 1) {    # directory should not have a .keepme
      if (-e "$_/.keepme") {
         print "$_/.keepme should be removed\n";
      }
   }
}




reply via email to

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