Annotation of embedaddon/php/win32/build/svnclean.js, revision 1.1.1.1
1.1 misho 1: /*
2: +----------------------------------------------------------------------+
3: | PHP Version 5 |
4: +----------------------------------------------------------------------+
5: | Copyright (c) 1997-2009 The PHP Group |
6: +----------------------------------------------------------------------+
7: | This source file is subject to version 3.01 of the PHP license, |
8: | that is bundled with this package in the file LICENSE, and is |
9: | available through the world-wide-web at the following url: |
10: | http://www.php.net/license/3_01.txt |
11: | If you did not receive a copy of the PHP license and are unable to |
12: | obtain it through the world-wide-web, please send a note to |
13: | license@php.net so we can mail you a copy immediately. |
14: +----------------------------------------------------------------------+
15: | Author: Wez Furlong <wez@thebrainroom.com> |
16: | Pierre A. Joye <pierre@php.net> |
17: +----------------------------------------------------------------------+
18: */
19:
20: /* $Id$ */
21: // Cleans up files that do not belong in the repository
22:
23: var FSO = WScript.CreateObject("Scripting.FileSystemObject");
24: var WshShell = WScript.CreateObject("WScript.Shell");
25: var STDOUT = WScript.StdOut;
26:
27: /* svn propget svn:ignore dirname */
28: function find_ignore(dirname)
29: {
30: dirname = "" + dirname;
31: dirname_len = dirname.length;
32:
33: if (!FSO.FolderExists(dirname) || (dirname_len >= 4 &&
34: dirname.substring(dirname_len - 4) == ".svn")) {
35: return;
36: }
37:
38: var f = FSO.GetFolder(dirname);
39: var fc = new Enumerator(f.SubFolders);
40:
41: for (; !fc.atEnd(); fc.moveNext()) {
42: find_ignore(fc.item());
43: }
44:
45: kill_from_ignore(dirname);
46: }
47:
48: /* recursive remove using ignore props style wildcard matching;
49: * note that FSO.DeleteFolder and FSO.DeleteFile methods both
50: * accept wildcards, but that they are dangerous to use eg:
51: * "*.php" will match "*.phpt" */
52: function rm_r(filename)
53: {
54: if (FSO.FolderExists(filename)) {
55: var fc = new Enumerator(FSO.GetFolder(filename).SubFolders);
56:
57: for (; !fc.atEnd(); fc.moveNext()) {
58: rm_r(fc.item());
59: }
60:
61: fc = new Enumerator(FSO.GetFolder(filename).Files);
62:
63: for (; !fc.atEnd(); fc.moveNext()) {
64: FSO.DeleteFile(fc.item(), true);
65: }
66:
67: FSO.DeleteFolder(filename, true);
68: } else if (FSO.FileExists(filename)) {
69: FSO.DeleteFile(filename, true);
70: } else {
71: /* we need to handle wildcards here */
72: var foldername = FSO.GetParentFolderName(filename);
73:
74: if (foldername == "")
75: foldername = ".";
76:
77: var filename = FSO.GetFileName(filename);
78:
79: var retext = filename.replace(/\./g, '\\.');
80: retext = '^' + retext.replace(/\*/g, '.*') + "$";
81: var re = new RegExp(retext);
82:
83: var folder = FSO.GetFolder(foldername);
84: var fc = new Enumerator(folder.SubFolders);
85: for (; !fc.atEnd(); fc.moveNext()) {
86:
87: var item = FSO.GetFileName(fc.item());
88:
89: if (item.match(re)) {
90: rm_r(fc.item());
91: }
92: }
93: var fc = new Enumerator(folder.Files);
94: for (; !fc.atEnd(); fc.moveNext()) {
95: item = FSO.GetFileName(fc.item());
96:
97: if (item.match(re)) {
98: FSO.DeleteFile(fc.item(), true);
99: }
100: }
101: }
102: }
103:
104: function kill_from_ignore(dirname)
105: {
106: var l;
107: var e = WshShell.Exec("svn propget svn:ignore " + dirname);
108: var re = /^(config\.nice.*)|(\*)$/i;
109:
110: while (!e.StdOut.atEndOfStream) {
111: l = e.StdOut.ReadLine();
112: if (l.length == 0 || re.test(l)) {
113: continue;
114: }
115: rm_r(dirname + l);
116: }
117:
118: }
119:
120: find_ignore(".");
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>