Mercurial > hg > truffle
diff mxtool/mx.py @ 20125:374b48caeb9c
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 01 Apr 2015 19:30:25 +0200 |
parents | 1b9841bb304d |
children | 8dec9eea3186 |
line wrap: on
line diff
--- a/mxtool/mx.py Wed Apr 01 19:30:14 2015 +0200 +++ b/mxtool/mx.py Wed Apr 01 19:30:25 2015 +0200 @@ -837,6 +837,24 @@ else: return None + def locate(self, sDir, patterns=None, abortOnError=True): + try: + if patterns is None: + patterns = [] + elif not isinstance(patterns, list): + patterns = [patterns] + return subprocess.check_output(['hg', 'locate', '-R', sDir] + patterns).split('\n') + except OSError: + warn(self.missing) + except subprocess.CalledProcessError as e: + if e.returncode == 1: + # hg locate returns 1 if no matches were found + return [] + if abortOnError: + abort('failed to locate') + else: + return None + def _load_suite_dict(mxDir): suffix = 1 @@ -4664,8 +4682,13 @@ def fsckprojects(args): """find directories corresponding to deleted Java projects and delete them""" + if not sys.stdout.isatty(): + log('fsckprojects command must be run in an interactive shell') + return + hg = HgConfig() for suite in suites(True): projectDirs = [p.dir for p in suite.projects] + distIdeDirs = [d.get_ide_project_dir() for d in suite.dists if d.get_ide_project_dir() is not None] for dirpath, dirnames, files in os.walk(suite.dir): if dirpath == suite.dir: # no point in traversing .hg or lib/ @@ -4673,13 +4696,20 @@ elif dirpath in projectDirs: # don't traverse subdirs of an existing project in this suite dirnames[:] = [] + elif dirpath in distIdeDirs: + # don't traverse subdirs of an existing distributions in this suite + dirnames[:] = [] else: - projectConfigFiles = frozenset(['.classpath', 'nbproject']) + projectConfigFiles = frozenset(['.classpath', '.project', 'nbproject']) indicators = projectConfigFiles.intersection(files) if len(indicators) != 0: - if not sys.stdout.isatty() or ask_yes_no(dirpath + ' looks like a removed project -- delete it', 'n'): - shutil.rmtree(dirpath) - log('Deleted ' + dirpath) + indicators = [os.path.relpath(join(dirpath, i), suite.dir) for i in indicators] + indicatorsInHg = hg.locate(suite.dir, indicators) + # Only proceed if there are indicator files that are not under HG + if len(indicators) > len(indicatorsInHg): + if not sys.stdout.isatty() or ask_yes_no(dirpath + ' looks like a removed project -- delete it', 'n'): + shutil.rmtree(dirpath) + log('Deleted ' + dirpath) def javadoc(args, parser=None, docDir='javadoc', includeDeps=True, stdDoclet=True): """generate javadoc for some/all Java projects"""