changeset 7913:0df252296c8d

added fsckproject command to mx for removing directories corresponding to deleted projects. This command is also called from the ideinit command (GRAAL-90)
author Doug Simon <doug.simon@oracle.com>
date Sat, 02 Mar 2013 13:52:56 +0400
parents 06ecee106195
children 3b5578749256
files mxtool/mx.py
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mxtool/mx.py	Sat Mar 02 09:53:47 2013 +0400
+++ b/mxtool/mx.py	Sat Mar 02 13:52:56 2013 +0400
@@ -2474,6 +2474,25 @@
     """(re)generate Eclipse and NetBeans project configurations"""
     eclipseinit(args, suite)
     netbeansinit(args, suite)
+    fsckprojects([])
+
+def fsckprojects(args):
+    """find directories corresponding to deleted Java projects and delete them"""
+    for suite in suites():
+        projectDirs = [p.dir for p in suite.projects]
+        for root, dirnames, files in os.walk(suite.dir):
+            currentDir = join(suite.dir, root)
+            if currentDir in projectDirs:
+                # don't traverse subdirs of an existing project
+                dirnames[:] = []
+            else:
+                projectConfigFiles = frozenset(['.classpath', 'nbproject'])
+                indicators = projectConfigFiles.intersection(files)
+                if len(indicators) != 0:
+                    response = raw_input(currentDir + ' looks like a removed project -- delete it? [yn]: ')
+                    if 'y' == response:
+                        shutil.rmtree(currentDir)
+                        log('Deleted ' + currentDir)
 
 def javadoc(args, parser=None, docDir='javadoc', includeDeps=True):
     """generate javadoc for some/all Java projects"""
@@ -2926,6 +2945,7 @@
     'eclipseinit': [eclipseinit, ''],
     'eclipseformat': [eclipseformat, ''],
     'findclass': [findclass, ''],
+    'fsckprojects': [fsckprojects, ''],
     'help': [help_, '[command]'],
     'ideclean': [ideclean, ''],
     'ideinit': [ideinit, ''],