コード例 #1
0
    repo_path = lib.repo_path()
    repo = pygit2.Repository(repo_path)
    index = lib.git_sort.SortIndex(repo)

    # (before, inside, after, set(inside),)
    local, base, remote = ((
        s[0],
        s[1],
        s[2],
        set([
            series_conf.firstword(l) for l in s[1]
            if series_conf.filter_patches(l)
        ]),
    ) for s in [
        series_conf.split(open(s_path)) for s_path in (
            local_path,
            base_path,
            remote_path,
        )
    ])

    added = remote[3] - base[3]
    removed = base[3] - remote[3]
    moved = set(lib.list_moved_patches(base[1], remote[1]))

    if added or removed:
        print("%d commits added, %d commits removed from base to remote." % (
            len(added),
            len(removed),
        ))
コード例 #2
0
    if filter_mode:
        f = sys.stdin
    else:
        try:
            f = open(path)
        except FileNotFoundError as err:
            print("Error: %s" % (err, ), file=sys.stderr)
            sys.exit(1)
        series_path = os.path.abspath(path)
    lines = f.readlines()

    if args.prefix is not None:
        os.chdir(args.prefix)

    try:
        before, inside, after = series_conf.split(lines)
    except exc.KSNotFound as err:
        if filter_mode:
            before = []
            inside = lines
            after = []
        elif args.check:
            # no sorted section
            sys.exit(0)
        else:
            print("Error: %s" % (err, ), file=sys.stderr)
            sys.exit(1)

    try:
        input_entries = lib.parse_inside(index, inside, args.upstream)
    except exc.KSError as err:
コード例 #3
0
ファイル: lib.py プロジェクト: openSUSE/kernel-source
def sequence_insert(series, rev, top):
    """
    top is the top applied patch, None if none are applied.

    Caller must chdir to where the entries in series can be found.

    Returns the name of the new top patch and how many must be applied/popped.
    """
    git_dir = repo_path()
    repo = pygit2.Repository(git_dir)
    index = git_sort.SortIndex(repo)

    try:
        commit = str(repo.revparse_single(rev).id)
    except ValueError:
        raise exc.KSError("\"%s\" is not a valid revision." % (rev,))
    except KeyError:
        raise exc.KSError("Revision \"%s\" not found in \"%s\"." % (
            rev, git_dir,))

    marker = "# new commit"
    new_entry = InputEntry(marker)
    try:
        new_entry.dest = index.lookup(commit)
    except git_sort.GSKeyError:
        raise exc.KSError(
            "Commit %s not found in git-sort index. If it is from a "
            "repository and branch pair which is not listed in \"remotes\", "
            "please add it and submit a patch." % (commit,))
    new_entry.dest_head = new_entry.dest.head

    try:
        before, inside, after = series_conf.split(series)
    except exc.KSNotFound as err:
        raise exc.KSError(err)
    before, after = map(series_conf.filter_series, (before, after,))
    current_patches = flatten([before, series_conf.filter_series(inside), after])

    if top is None:
        top_index = 0
    else:
        top_index = current_patches.index(top) + 1

    input_entries = parse_inside(index, inside, False)
    input_entries.append(new_entry)

    sorted_entries = series_sort(index, input_entries)
    new_patches = flatten([
        before,
        [line.strip() for lines in sorted_entries.values() for line in lines],
        after,
    ])
    commit_pos = new_patches.index(marker)
    if commit_pos == 0:
        # should be inserted first in series
        name = ""
    else:
        name = new_patches[commit_pos - 1]
    del new_patches[commit_pos]

    if new_patches != current_patches:
        raise exc.KSError("Subseries is not sorted. "
                      "Please run scripts/series_sort.py.")

    return (name, commit_pos - top_index,)
コード例 #4
0
ファイル: series_sort.py プロジェクト: openSUSE/kernel-source
    if filter_mode:
        f = sys.stdin
    else:
        try:
            f = open(path)
        except FileNotFoundError as err:
            print("Error: %s" % (err,), file=sys.stderr)
            sys.exit(1)
        series_path = os.path.abspath(path)
    lines = f.readlines()

    if args.prefix is not None:
        os.chdir(args.prefix)

    try:
        before, inside, after = series_conf.split(lines)
    except exc.KSNotFound as err:
        if filter_mode:
            before = []
            inside = lines
            after = []
        elif args.check:
            # no sorted section
            sys.exit(0)
        else:
            print("Error: %s" % (err,), file=sys.stderr)
            sys.exit(1)

    try:
        input_entries = lib.parse_inside(index, inside, args.upstream)
    except exc.KSError as err:
コード例 #5
0
ファイル: merge_tool.py プロジェクト: openSUSE/kernel-source

if __name__ == "__main__":
    local_path, base_path, remote_path, merged_path = sys.argv[1:5]

    repo_path = lib.repo_path()
    repo = pygit2.Repository(repo_path)
    index = lib.git_sort.SortIndex(repo)

    # (before, inside, after, set(inside),)
    local, base, remote = (
        (s[0], s[1], s[2], set([series_conf.firstword(l)
                                for l in s[1]
                                if series_conf.filter_patches(l)]),)
        for s in [
            series_conf.split(open(s_path))
            for s_path in (local_path, base_path, remote_path,)
        ]
    )

    added = remote[3] - base[3]
    removed = base[3] - remote[3]
    moved = set(lib.list_moved_patches(base[1], remote[1]))

    if added or removed:
        print("%d commits added, %d commits removed from base to remote." %
              (len(added), len(removed),))
    if moved:
        print("%d commits changed section from base to remote." % (len(moved),))
    dup_add_nb = len(local[3] & added)
    dup_rem_nb = len(removed) - len(local[3] & removed)
コード例 #6
0
ファイル: lib.py プロジェクト: PandaWei/kernel-source
def sequence_insert(series, rev, top):
    """
    top is the top applied patch, None if none are applied.

    Caller must chdir to where the entries in series can be found.

    Returns the name of the new top patch and how many must be applied/popped.
    """
    git_dir = repo_path()
    repo = pygit2.Repository(git_dir)
    index = git_sort.SortIndex(repo)

    try:
        commit = str(repo.revparse_single(rev).id)
    except ValueError:
        raise exc.KSError("\"%s\" is not a valid revision." % (rev, ))
    except KeyError:
        raise exc.KSError("Revision \"%s\" not found in \"%s\"." % (
            rev,
            git_dir,
        ))

    marker = "# new commit"
    new_entry = InputEntry(marker)
    try:
        new_entry.dest = index.lookup(commit)
    except git_sort.GSKeyError:
        raise exc.KSError(
            "Commit %s not found in git-sort index. If it is from a "
            "repository and branch pair which is not listed in \"remotes\", "
            "please add it and submit a patch." % (commit, ))
    new_entry.dest_head = new_entry.dest.head

    try:
        before, inside, after = series_conf.split(series)
    except exc.KSNotFound as err:
        raise exc.KSError(err)
    before, after = map(series_conf.filter_series, (
        before,
        after,
    ))
    current_patches = flatten(
        [before, series_conf.filter_series(inside), after])

    if top is None:
        top_index = 0
    else:
        top_index = current_patches.index(top) + 1

    input_entries = parse_inside(index, inside, False)
    input_entries.append(new_entry)

    sorted_entries = series_sort(index, input_entries)
    new_patches = flatten([
        before,
        [line.strip() for lines in sorted_entries.values() for line in lines],
        after,
    ])
    commit_pos = new_patches.index(marker)
    if commit_pos == 0:
        # should be inserted first in series
        name = ""
    else:
        name = new_patches[commit_pos - 1]
    del new_patches[commit_pos]

    if new_patches != current_patches:
        raise exc.KSError("Subseries is not sorted. "
                          "Please run scripts/series_sort.py.")

    return (
        name,
        commit_pos - top_index,
    )
コード例 #7
0
ファイル: merge_tool.py プロジェクト: PandaWei/kernel-source

if __name__ == "__main__":
    local_path, base_path, remote_path, merged_path = sys.argv[1:5]

    repo_path = lib.repo_path()
    repo = pygit2.Repository(repo_path)
    index = lib.git_sort.SortIndex(repo)

    # (before, inside, after, set(inside),)
    local, base, remote = (
        (s[0], s[1], s[2], set([series_conf.firstword(l)
                                for l in s[1]
                                if series_conf.filter_patches(l)]),)
        for s in [
            series_conf.split(open(s_path))
            for s_path in (local_path, base_path, remote_path,)
        ]
    )

    added = remote[3] - base[3]
    removed = base[3] - remote[3]
    moved = set(lib.list_moved_patches(base[1], remote[1]))

    if added or removed:
        print("%d commits added, %d commits removed from base to remote." %
              (len(added), len(removed),))
    if moved:
        print("%d commits changed section from base to remote." % (len(moved),))
    dup_add_nb = len(local[3] & added)
    dup_rem_nb = len(removed) - len(local[3] & removed)