summaryrefslogtreecommitdiff
path: root/buildscripts/PhpDocumentor/scripts/add_cvs.php
blob: 8b1145d07b0f6848ff598da8857cf54b51fdf056 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
//
// +------------------------------------------------------------------------+
// | phpDocumentor                                                          |
// +------------------------------------------------------------------------+
// | Copyright (c) 2000-2003 Joshua Eichorn, Gregory Beaver                 |
// | Email         jeichorn@phpdoc.org, cellog@phpdoc.org                   |
// | Web           http://www.phpdoc.org                                    |
// | Mirror        http://phpdocu.sourceforge.net/                          |
// | PEAR          http://pear.php.net/package/PhpDocumentor                |
// +------------------------------------------------------------------------+
// | This source file is subject to version 3.00 of the PHP License,        |
// | that is available at http://www.php.net/license/3_0.txt.               |
// | If you did not receive a copy of the PHP license and are unable to     |
// | obtain it through the world-wide-web, please send a note to            |
// | license@php.net so we can mail you a copy immediately.                 |
// +------------------------------------------------------------------------+
//
/**
 * CVS file adding iterator
 *
 * This file iterates over a directory, and adds everything to CVS that is
 * found, ignoring any error messages, until all files in each directory
 * and subdirectory have been added to cvs.  It then commits the files to cvs
 * @package phpDocumentor
 * @author Greg Beaver <cellog@php.net>
 * @copyright Copyright 2003, Greg Beaver
 * @version 1.0
 */
/**#@+
 * phpDocumentor include files.  If you don't have phpDocumentor, go get it!
 * Your php life will be changed forever
 */
$dir = realpath(dirname(__FILE__).'/..');
require_once("$dir/phpDocumentor/common.inc.php");
require_once("$dir/phpDocumentor/Io.inc");
/**#@-*/

/**
* Physical location on this computer of the package to parse
* @global string $cvsadd_directory
*/
$cvsadd_directory = realpath('.');
/**
* Comma-separated list of files and directories to ignore
*
* This uses wildcards * and ? to remove extra files/directories that are
* not part of the package or release
* @global string $ignore
*/
$ignore = array('CVS/');

/******************************************************************************
*       Don't change anything below here unless you're adventuresome          *
*******************************************************************************/

/**
 * @global Io $files
 */
$files = new Io;

$allfiles = $files->dirList($cvsadd_directory);
/**#@+
 * Sorting functions for the file list
 * @param string
 * @param string
 */
function sortfiles($a, $b)
{
	return strnatcasecmp($a['file'],$b['file']);
}

function mystrucsort($a, $b)
{
	if (is_numeric($a) && is_string($b)) return 1;
	if (is_numeric($b) && is_string($a)) return -1;
	if (is_numeric($a) && is_numeric($b))
	{
		if ($a > $b) return 1;
		if ($a < $b) return -1;
		if ($a == $b) return 0;
	}
	return strnatcasecmp($a,$b);
}
/**#@-*/

$struc = array();
foreach($allfiles as $file)
{
	if ($files->checkIgnore(basename($file),dirname($file),$ignore, false))
    {
//        print 'Ignoring '.$file."<br>\n";
        continue;
    }
	$path = substr(dirname($file),strlen(str_replace('\\','/',realpath($cvsadd_directory)))+1);
	if (!$path) $path = '/';
	$file = basename($file);
	$ext = array_pop(explode('.',$file));
	if (strlen($ext) == strlen($file)) $ext = '';
	$struc[$path][] = array('file' => $file,'ext' => $ext);
}
uksort($struc,'strnatcasecmp');
foreach($struc as $key => $ind)
{
	usort($ind,'sortfiles');
	$struc[$key] = $ind;
}
$tempstruc = $struc;
$struc = array('/' => $tempstruc['/']);
$bv = 0;
foreach($tempstruc as $key => $ind)
{
	$save = $key;
	if ($key != '/')
	{
        $struc['/'] = setup_dirs($struc['/'], explode('/',$key), $tempstruc[$key]);
	}
}
uksort($struc['/'],'mystrucsort');
/**
 * Recursively add files to cvs
 * @param array the sorted directory structure
 */
function addToCVS($struc)
{
	foreach($struc as $dir => $files)
	{
		if ($dir === '/')
		{
            print 'processing '.$dir . "\n";
			addToCVS($struc[$dir]);
			return;
		} else
		{
			if (!isset($files['file']))
			{
                print 'adding '.$dir . "\n";
                system('cvs add '.$dir);
                chdir($dir);
				addToCVS($files);
                chdir('..');
			} else
			{
                print 'adding '.$files['file'] . "\n";
                system('cvs add '.$files['file']);
                system('cvs commit -m "" '.$files['file']);
			}
		}
	}
}
addToCVS($struc);
print "\n".'done';
?>