Пример #1
0
def hg_history(path, interval):
    """Returns a list of Commit tuples with history
    for given Mercurial repo.
    """
    sep = '|'
    hg_log_template = sep.join(
        ['{node}', '{date|hgdate}', '{author|person}', '{desc|firstline}'])
    hg_log = r'hg log --template "%s\n"' % hg_log_template

    # add date filter if interval is specified
    date_filter = None
    since, until = interval
    if since and until:
        date_filter = '%s to %s' % (since.strftime(HG_TIME_FORMAT),
                                    until.strftime(HG_TIME_FORMAT))
    elif since:
        date_filter = '>' + since.strftime(HG_TIME_FORMAT)
    elif until:
        date_filter = '<' + until.strftime(HG_TIME_FORMAT)
    if date_filter:
        hg_log += ' --date "%s"' % date_filter

    log = exec_command(hg_log, path)

    history = []
    for line in log.splitlines():
        commit_hash, hg_time, author, message = line.split(sep, 3)
        hg_time = sum(map(int, hg_time.split()),
                      0)  # hg_time is 'local_timestamp timezone_offset'
        time = datetime.fromtimestamp(hg_time)
        history.append(Commit(commit_hash, time, author, message))

    return history
Пример #2
0
Файл: vcs.py Проект: Xion/coded4
def hg_history(path, interval):
    """Returns a list of Commit tuples with history
    for given Mercurial repo.
    """
    sep = '|'
    hg_log_template = sep.join(['{node}', '{date|hgdate}',
                                '{author|person}', '{desc|firstline}'])
    hg_log = r'hg log --template "%s\n"' % hg_log_template

    # add date filter if interval is specified
    date_filter = None
    since, until = interval
    if since and until:
        date_filter = '%s to %s' % (since.strftime(HG_TIME_FORMAT),
                                    until.strftime(HG_TIME_FORMAT))
    elif since:
        date_filter = '>' + since.strftime(HG_TIME_FORMAT)
    elif until:
        date_filter = '<' + until.strftime(HG_TIME_FORMAT)
    if date_filter:
        hg_log += ' --date "%s"' % date_filter

    log = exec_command(hg_log, path)

    history = []
    for line in log.splitlines():
        commit_hash, hg_time, author, message = line.split(sep, 3)
        hg_time = sum(map(int, hg_time.split()), 0)  # hg_time is 'local_timestamp timezone_offset'
        time = datetime.fromtimestamp(hg_time)
        history.append(Commit(commit_hash, time, author, message))

    return history
Пример #3
0
def git_history(path, interval):
    """Returns a list of Commit tuples with history for given Git repo. """
    sep = '|'
    git_log_format = sep.join(['%H', '%at', '%an', '%s'])
    git_log = 'git log --format=format:"%s"' % git_log_format

    since, until = interval
    if since:
        git_log += ' --since="%s"' % since.strftime(GIT_TIME_FORMAT)
    if until:
        git_log += ' --until="%s"' % until.strftime(GIT_TIME_FORMAT)

    log = exec_command(git_log, path)

    history = []
    for line in log.splitlines():
        commit_hash, timestamp, author, message = line.split(sep, 3)
        time = datetime.fromtimestamp(float(timestamp))
        history.append(Commit(commit_hash, time, author, message))

    return history
Пример #4
0
Файл: vcs.py Проект: Xion/coded4
def git_history(path, interval):
    """Returns a list of Commit tuples with history for given Git repo. """
    sep = '|'
    git_log_format = sep.join(['%H', '%at', '%an', '%s'])
    git_log = 'git log --format=format:"%s"' % git_log_format

    since, until = interval
    if since:
        git_log += ' --since="%s"' % since.strftime(GIT_TIME_FORMAT)
    if until:
        git_log += ' --until="%s"' % until.strftime(GIT_TIME_FORMAT)

    log = exec_command(git_log, path)

    history = []
    for line in log.splitlines():
        commit_hash, timestamp, author, message = line.split(sep, 3)
        time = datetime.fromtimestamp(float(timestamp))
        history.append(Commit(commit_hash, time, author, message))

    return history