Example #1
0
    def migrate_results_trees(self, expected_results, confirmed_results):
        cwd = os.getcwd()
        expected_results = moresh.relative_path(expected_results, cwd)
        confirmed_results = moresh.relative_path(confirmed_results, cwd)
        
        # Files are listed in 'topdown' order.
        logging.debug("Migrating %s to %s"%(confirmed_results,expected_results))
        common_files, unique_to_expected, unique_to_confirmed =\
            moresh.compare_trees(expected_results, confirmed_results, ["\.svn"])

        # Overwritten results
        for expected_filepath, confirmed_filepath in common_files:
            mv_cmd = 'mv -f %s %s'%(confirmed_filepath, expected_filepath)
            logging.debug(mv_cmd)
            os.system(mv_cmd)
        
        # Old expected results to be removed
        for expected_filepath in unique_to_expected:
            logging.debug("recursive_remove %s --force"%expected_filepath)
            version_control.recursive_remove(expected_filepath, '--force')

        # New expected results to be added
        for confirmed_filepath in unique_to_confirmed:
            expected_filepath = confirmed_filepath.replace('.confirmed', '')
            assert not os.path.exists(expected_filepath)

            if os.path.isdir(confirmed_filepath) \
               and moresh.is_recursively_empty(confirmed_filepath):
                continue # Do not add empty directory to version control.
            
            rename_cmd = 'os.rename("%s", "%s")'%(confirmed_filepath, expected_filepath)
            logging.debug(rename_cmd)
            eval(rename_cmd)

            version_control.recursive_add(expected_filepath)
Example #2
0
def report_unique_paths(unique_paths, alterpath, prefix=''):
    report = []
    for path in unique_paths:
        if os.path.islink(path):
            continue

        elif os.path.isdir(path):
            if path.endswith('.metadata'):
                raise RuntimeError 
                
            if not moresh.is_recursively_empty(path):
                report.append(
                    "%s%s seems to be a significant directory but corresponds to no "
                    "directory under the %s tree.\n" % (prefix, path, alterpath) )

        elif os.path.isfile(path):
            report.append(
                "%s%s seems to be a significant file but corresponds to no "
                "file under the %s tree.\n" % (prefix, path, alterpath) )

    return report
Example #3
0
    def migrate_results_trees(self, expected_results, confirmed_results):
        cwd = os.getcwd()
        expected_results = moresh.relative_path(expected_results, cwd)
        confirmed_results = moresh.relative_path(confirmed_results, cwd)

        # Files are listed in 'topdown' order.
        logging.debug("Migrating %s to %s" %
                      (confirmed_results, expected_results))
        common_files, unique_to_expected, unique_to_confirmed =\
            moresh.compare_trees(expected_results, confirmed_results, ["\.svn"])

        # Overwritten results
        for expected_filepath, confirmed_filepath in common_files:
            mv_cmd = 'mv -f %s %s' % (confirmed_filepath, expected_filepath)
            logging.debug(mv_cmd)
            os.system(mv_cmd)

        # Old expected results to be removed
        for expected_filepath in unique_to_expected:
            logging.debug("recursive_remove %s --force" % expected_filepath)
            version_control.recursive_remove(expected_filepath, '--force')

        # New expected results to be added
        for confirmed_filepath in unique_to_confirmed:
            expected_filepath = confirmed_filepath.replace('.confirmed', '')
            assert not os.path.exists(expected_filepath)

            if os.path.isdir(confirmed_filepath) \
               and moresh.is_recursively_empty(confirmed_filepath):
                continue  # Do not add empty directory to version control.

            rename_cmd = 'os.rename("%s", "%s")' % (confirmed_filepath,
                                                    expected_filepath)
            logging.debug(rename_cmd)
            eval(rename_cmd)

            version_control.recursive_add(expected_filepath)