예제 #1
0
    def __save_log_entries(self, url, branch, save_to_db=False, verbose=False):
        # if the branch name contains a slash separator,
        #  assume the final element is the release/branch name
        idx = branch.rfind("/")
        tag_name = branch if idx < 0 else branch[idx + 1:]

        if verbose:
            print("%s %s:%s" %
                  ("Saving" if save_to_db else "Loading", self.__name, branch))

        # build the log entry generator as a standalone object
        #  so we can close it if we exit the loop early
        log_gen = svn_log(url, revision="HEAD", end_revision=1)

        # update a copy of the cache in case we get interrupted
        new_cache = None if self.__cached_entries is None \
          else self.__cached_entries.copy()

        # loop through all the log entries
        for logentry in log_gen:
            # if we've already seen this entry, then we've definitely seen
            #  all the earlier entries
            if new_cache is not None and \
              logentry.revision in new_cache:
                # since there are no more interesting entries, exit the loop
                break

            entry = SVNEntry(tag_name, branch, logentry.revision,
                             logentry.author, logentry.date_string,
                             logentry.num_lines, logentry.filedata,
                             logentry.loglines)

            # if necessary, initialize the cache dictionary
            if new_cache is None:
                new_cache = {}

            # save this entry
            new_cache[entry.revision] = entry
            if save_to_db:
                self.__save_entry_to_database(entry)

        # close the generator so it cleans up the `svn log` process
        log_gen.close()

        self.__cached_entries = new_cache
예제 #2
0
    project_dict = project_config.parse_config_file(options.config_file)

    print 'calculate file size...'
    array_dict = calc_file_size(args[0])

    print 'check file author...'
    svn.set_svn_tool('svn')
    result_array = {}
    for d in array_dict:
        if check_path_with_filter(d['path'], project_dict):
            continue
        result, conditions = check_path_with_match(d['path'], project_dict)
        if result:
            for condition in conditions:
                if 'size_large_than' in condition:
                    log_string = svn.svn_log(d['path'], 1)
                    log_name = butils.get_lastest_name_from_svn_log(log_string)
                    if log_name in result_array:
                        pass
                    else:
                        result_array[log_name] = []
                    result_array[log_name].append(
                        (d['size'], d['path'], condition['size_large_than']))
                    break

    print 'write result to file...'
    with open(options.result_file, 'w') as rfile:
        rfile.writelines('Here are some files too large:\n')
        for name in result_array:
            rfile.writelines('\n')
            rfile.writelines('Author: ' + name + '\n')
예제 #3
0
def __add_revisions(proj_url,
                    orig_wrkspc,
                    new_trunk,
                    logfile_prefix,
                    startrev,
                    endrev,
                    orig_subrel=None,
                    new_reldir=None,
                    pause_for_release=False,
                    debug=False,
                    verbose=False):
    subdirs = {}
    for entry in svn_log(proj_url, revision=startrev, end_revision=endrev):
        filedata = []
        for modtype, filename in entry.filedata:
            # ignore files outside the domhub-tools project
            if not filename.startswith(logfile_prefix):
                continue

            # trim initial path from filename
            filename = filename[len(logfile_prefix):]

            # ignore some paths
            if filename.find("Attic") >= 0 or \
              filename.startswith("trunk/moat/") or \
              filename.startswith("trunk/domapp/"):
                continue

            # split filename into individual pieces
            pathparts = filename.split(os.sep)

            # ignore stuff outside 'trunk'
            if pathparts[0] != "trunk":
                continue

            # only care about stuff in development directories
            if len(pathparts) >= 2 and \
              pathparts[1] not in ("trunk", "rel-100", "rel-200"):
                if not filename.startswith("tags"):
                    print("\t\t%s" % os.sep.join(pathparts[:2]))
                continue

            if len(pathparts) == 2:
                filedata.append((modtype, pathparts[0], pathparts[1]))
            else:
                subdir = os.sep.join(pathparts[:2])
                subdirs[subdir] = 1

                filedata.append((modtype, subdir, filename[len(subdir):]))

        removed = __remove_empty_moat_domapp(new_trunk,
                                             remove_svn=True,
                                             debug=debug,
                                             verbose=verbose)
        if removed:
            orig_trunk = os.path.join(orig_wrkspc, "trunk")
            __remove_empty_moat_domapp(orig_trunk,
                                       remove_svn=False,
                                       debug=debug,
                                       verbose=verbose)

        if not removed and len(filedata) == 0:
            print("Ignore r%d" % entry.revision)
            continue

        __update_for_revision(orig_wrkspc,
                              list(subdirs.keys()),
                              new_trunk,
                              entry.revision,
                              "\n".join(entry.loglines),
                              pause_for_release=pause_for_release,
                              debug=debug,
                              verbose=verbose)

        if orig_subrel is not None and new_reldir is not None:
            __update_for_revision(orig_wrkspc, (orig_subrel, ),
                                  new_reldir,
                                  entry.revision,
                                  "\n".join(entry.loglines),
                                  pause_for_release=pause_for_release,
                                  debug=debug,
                                  verbose=verbose)
예제 #4
0
    project_dict = project_config.parse_config_file(options.config_file)

    print 'calculate file size...'
    array_dict = calc_file_size(args[0])

    print 'check file author...'
    svn.set_svn_tool('svn')
    result_array = {}
    for d in array_dict:
        if check_path_with_filter(d['path'], project_dict):
            continue
        result, conditions = check_path_with_match(d['path'], project_dict)
        if result:
            for condition in conditions:
                if 'size_large_than' in condition:
                    log_string = svn.svn_log(d['path'], 1)
                    log_name = butils.get_lastest_name_from_svn_log(log_string)
                    if log_name in result_array:
                        pass
                    else:
                        result_array[log_name] = []
                    result_array[log_name].append((d['size'], d['path'], condition['size_large_than']))
                    break

    print 'write result to file...'
    with open(options.result_file, 'w') as rfile:
        rfile.writelines('Here are some files too large:\n')
        for name in result_array:
            rfile.writelines('\n')
            rfile.writelines('Author: ' + name + '\n')
            for m in result_array[name]:
예제 #5
0
    parser = _create_option_parser()
    (options, args) = parser.parse_args()
    _check_options_and_args(options, args)

    project_dict = project_config.parse_config_file(options.config_file)

    svn.set_svn_tool("svn")
    result_dict = {}

    print "analyze lint result xml..."
    resource_array = check_unused_resources(options.lint_result, project_dict)
    svn.set_svn_tool("svn")
    for resource in resource_array:
        if check_path_with_filter(resource, project_dict):
            continue
        log_string = svn.svn_log(options.android_project_root + os.sep + resource, 1)
        log_name = butils.get_lastest_name_from_svn_log(log_string)
        if log_name is not None:
            if log_name in result_dict:
                pass
            else:
                result_dict[log_name] = []
            result_dict[log_name].append(resource)

    print "write analysis result to file..."
    with open(options.result_file, "w") as rfile:
        rfile.writelines("Here may be some unused resources:\n")
        for name in result_dict:
            rfile.writelines("\n")
            rfile.writelines("Author: " + name + "\n")
            for res in result_dict[name]:
예제 #6
0
    parser = _create_option_parser()
    (options, args) = parser.parse_args()
    _check_options_and_args(options, args)

    project_dict = project_config.parse_config_file(options.config_file)

    svn.set_svn_tool('svn')
    result_dict = {}

    print 'analyze lint result xml...'
    resource_array = check_unused_resources(options.lint_result, project_dict)
    svn.set_svn_tool('svn')
    for resource in resource_array:
        if check_path_with_filter(resource, project_dict):
            continue
        log_string = svn.svn_log(
            options.android_project_root + os.sep + resource, 1)
        log_name = butils.get_lastest_name_from_svn_log(log_string)
        if log_name is not None:
            if log_name in result_dict:
                pass
            else:
                result_dict[log_name] = []
            result_dict[log_name].append(resource)

    print 'write analysis result to file...'
    with open(options.result_file, 'w') as rfile:
        rfile.writelines('Here may be some unused resources:\n')
        for name in result_dict:
            rfile.writelines('\n')
            rfile.writelines('Author: ' + name + '\n')
            for res in result_dict[name]: