Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
20124:a9c8df485789 | 20125:374b48caeb9c |
---|---|
832 except OSError: | 832 except OSError: |
833 warn(self.missing) | 833 warn(self.missing) |
834 except subprocess.CalledProcessError: | 834 except subprocess.CalledProcessError: |
835 if abortOnError: | 835 if abortOnError: |
836 abort('failed to get status') | 836 abort('failed to get status') |
837 else: | |
838 return None | |
839 | |
840 def locate(self, sDir, patterns=None, abortOnError=True): | |
841 try: | |
842 if patterns is None: | |
843 patterns = [] | |
844 elif not isinstance(patterns, list): | |
845 patterns = [patterns] | |
846 return subprocess.check_output(['hg', 'locate', '-R', sDir] + patterns).split('\n') | |
847 except OSError: | |
848 warn(self.missing) | |
849 except subprocess.CalledProcessError as e: | |
850 if e.returncode == 1: | |
851 # hg locate returns 1 if no matches were found | |
852 return [] | |
853 if abortOnError: | |
854 abort('failed to locate') | |
837 else: | 855 else: |
838 return None | 856 return None |
839 | 857 |
840 def _load_suite_dict(mxDir): | 858 def _load_suite_dict(mxDir): |
841 | 859 |
4662 if not refreshOnly: | 4680 if not refreshOnly: |
4663 fsckprojects([]) | 4681 fsckprojects([]) |
4664 | 4682 |
4665 def fsckprojects(args): | 4683 def fsckprojects(args): |
4666 """find directories corresponding to deleted Java projects and delete them""" | 4684 """find directories corresponding to deleted Java projects and delete them""" |
4685 if not sys.stdout.isatty(): | |
4686 log('fsckprojects command must be run in an interactive shell') | |
4687 return | |
4688 hg = HgConfig() | |
4667 for suite in suites(True): | 4689 for suite in suites(True): |
4668 projectDirs = [p.dir for p in suite.projects] | 4690 projectDirs = [p.dir for p in suite.projects] |
4691 distIdeDirs = [d.get_ide_project_dir() for d in suite.dists if d.get_ide_project_dir() is not None] | |
4669 for dirpath, dirnames, files in os.walk(suite.dir): | 4692 for dirpath, dirnames, files in os.walk(suite.dir): |
4670 if dirpath == suite.dir: | 4693 if dirpath == suite.dir: |
4671 # no point in traversing .hg or lib/ | 4694 # no point in traversing .hg or lib/ |
4672 dirnames[:] = [d for d in dirnames if d not in ['.hg', 'lib']] | 4695 dirnames[:] = [d for d in dirnames if d not in ['.hg', 'lib']] |
4673 elif dirpath in projectDirs: | 4696 elif dirpath in projectDirs: |
4674 # don't traverse subdirs of an existing project in this suite | 4697 # don't traverse subdirs of an existing project in this suite |
4675 dirnames[:] = [] | 4698 dirnames[:] = [] |
4699 elif dirpath in distIdeDirs: | |
4700 # don't traverse subdirs of an existing distributions in this suite | |
4701 dirnames[:] = [] | |
4676 else: | 4702 else: |
4677 projectConfigFiles = frozenset(['.classpath', 'nbproject']) | 4703 projectConfigFiles = frozenset(['.classpath', '.project', 'nbproject']) |
4678 indicators = projectConfigFiles.intersection(files) | 4704 indicators = projectConfigFiles.intersection(files) |
4679 if len(indicators) != 0: | 4705 if len(indicators) != 0: |
4680 if not sys.stdout.isatty() or ask_yes_no(dirpath + ' looks like a removed project -- delete it', 'n'): | 4706 indicators = [os.path.relpath(join(dirpath, i), suite.dir) for i in indicators] |
4681 shutil.rmtree(dirpath) | 4707 indicatorsInHg = hg.locate(suite.dir, indicators) |
4682 log('Deleted ' + dirpath) | 4708 # Only proceed if there are indicator files that are not under HG |
4709 if len(indicators) > len(indicatorsInHg): | |
4710 if not sys.stdout.isatty() or ask_yes_no(dirpath + ' looks like a removed project -- delete it', 'n'): | |
4711 shutil.rmtree(dirpath) | |
4712 log('Deleted ' + dirpath) | |
4683 | 4713 |
4684 def javadoc(args, parser=None, docDir='javadoc', includeDeps=True, stdDoclet=True): | 4714 def javadoc(args, parser=None, docDir='javadoc', includeDeps=True, stdDoclet=True): |
4685 """generate javadoc for some/all Java projects""" | 4715 """generate javadoc for some/all Java projects""" |
4686 | 4716 |
4687 parser = ArgumentParser(prog='mx javadoc') if parser is None else parser | 4717 parser = ArgumentParser(prog='mx javadoc') if parser is None else parser |