/xampp/php/PEAR/PhpDocumentor/scripts/add_cvs.php

https://github.com/edmondscommerce/XAMPP-Magento-Demo-Site · PHP · 153 lines · 86 code · 6 blank · 61 comment · 18 complexity · 5a177d782c0416dab4f1bb68a30ef29f MD5 · raw file

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | phpDocumentor |
  5. // +------------------------------------------------------------------------+
  6. // | Copyright (c) 2000-2003 Joshua Eichorn, Gregory Beaver |
  7. // | Email jeichorn@phpdoc.org, cellog@phpdoc.org |
  8. // | Web http://www.phpdoc.org |
  9. // | Mirror http://phpdocu.sourceforge.net/ |
  10. // | PEAR http://pear.php.net/package/PhpDocumentor |
  11. // +------------------------------------------------------------------------+
  12. // | This source file is subject to version 3.00 of the PHP License, |
  13. // | that is available at http://www.php.net/license/3_0.txt. |
  14. // | If you did not receive a copy of the PHP license and are unable to |
  15. // | obtain it through the world-wide-web, please send a note to |
  16. // | license@php.net so we can mail you a copy immediately. |
  17. // +------------------------------------------------------------------------+
  18. //
  19. /**
  20. * CVS file adding iterator
  21. *
  22. * This file iterates over a directory, and adds everything to CVS that is
  23. * found, ignoring any error messages, until all files in each directory
  24. * and subdirectory have been added to cvs. It then commits the files to cvs
  25. * @package phpDocumentor
  26. * @author Greg Beaver <cellog@php.net>
  27. * @copyright Copyright 2003, Greg Beaver
  28. * @version 1.0
  29. */
  30. /**#@+
  31. * phpDocumentor include files. If you don't have phpDocumentor, go get it!
  32. * Your php life will be changed forever
  33. */
  34. $dir = realpath(dirname(__FILE__).'/..');
  35. require_once("$dir/phpDocumentor/common.inc.php");
  36. require_once("$dir/phpDocumentor/Io.inc");
  37. /**#@-*/
  38. /**
  39. * Physical location on this computer of the package to parse
  40. * @global string $cvsadd_directory
  41. */
  42. $cvsadd_directory = realpath('.');
  43. /**
  44. * Comma-separated list of files and directories to ignore
  45. *
  46. * This uses wildcards * and ? to remove extra files/directories that are
  47. * not part of the package or release
  48. * @global string $ignore
  49. */
  50. $ignore = array('CVS/');
  51. /******************************************************************************
  52. * Don't change anything below here unless you're adventuresome *
  53. *******************************************************************************/
  54. /**
  55. * @global Io $files
  56. */
  57. $files = new Io;
  58. $allfiles = $files->dirList($cvsadd_directory);
  59. /**#@+
  60. * Sorting functions for the file list
  61. * @param string
  62. * @param string
  63. */
  64. function sortfiles($a, $b)
  65. {
  66. return strnatcasecmp($a['file'],$b['file']);
  67. }
  68. function mystrucsort($a, $b)
  69. {
  70. if (is_numeric($a) && is_string($b)) return 1;
  71. if (is_numeric($b) && is_string($a)) return -1;
  72. if (is_numeric($a) && is_numeric($b))
  73. {
  74. if ($a > $b) return 1;
  75. if ($a < $b) return -1;
  76. if ($a == $b) return 0;
  77. }
  78. return strnatcasecmp($a,$b);
  79. }
  80. /**#@-*/
  81. $struc = array();
  82. foreach($allfiles as $file)
  83. {
  84. if ($files->checkIgnore(basename($file),dirname($file),$ignore, false))
  85. {
  86. // print 'Ignoring '.$file."<br>\n";
  87. continue;
  88. }
  89. $path = substr(dirname($file),strlen(str_replace('\\','/',realpath($cvsadd_directory)))+1);
  90. if (!$path) $path = '/';
  91. $file = basename($file);
  92. $ext = array_pop(explode('.',$file));
  93. if (strlen($ext) == strlen($file)) $ext = '';
  94. $struc[$path][] = array('file' => $file,'ext' => $ext);
  95. }
  96. uksort($struc,'strnatcasecmp');
  97. foreach($struc as $key => $ind)
  98. {
  99. usort($ind,'sortfiles');
  100. $struc[$key] = $ind;
  101. }
  102. $tempstruc = $struc;
  103. $struc = array('/' => $tempstruc['/']);
  104. $bv = 0;
  105. foreach($tempstruc as $key => $ind)
  106. {
  107. $save = $key;
  108. if ($key != '/')
  109. {
  110. $struc['/'] = setup_dirs($struc['/'], explode('/',$key), $tempstruc[$key]);
  111. }
  112. }
  113. uksort($struc['/'],'mystrucsort');
  114. /**
  115. * Recursively add files to cvs
  116. * @param array the sorted directory structure
  117. */
  118. function addToCVS($struc)
  119. {
  120. foreach($struc as $dir => $files)
  121. {
  122. if ($dir === '/')
  123. {
  124. print 'processing '.$dir . "\n";
  125. addToCVS($struc[$dir]);
  126. return;
  127. } else
  128. {
  129. if (!isset($files['file']))
  130. {
  131. print 'adding '.$dir . "\n";
  132. system('cvs add '.$dir);
  133. chdir($dir);
  134. addToCVS($files);
  135. chdir('..');
  136. } else
  137. {
  138. print 'adding '.$files['file'] . "\n";
  139. system('cvs add '.$files['file']);
  140. system('cvs commit -m "" '.$files['file']);
  141. }
  142. }
  143. }
  144. }
  145. addToCVS($struc);
  146. print "\n".'done';
  147. ?>