diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index c1113b8..d22e1a3 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -84,20 +84,31 @@ def _get_pr_info(repo_obj, orig_repo, branch_from, branch_to): if not repo_obj.is_empty and not orig_repo.is_empty: orig_commit = orig_repo[ orig_repo.lookup_branch(branch_to).get_object().hex] + repo_commit = repo_obj[commitid] - master_commits = [ - commit.oid.hex - for commit in orig_repo.walk( - orig_commit.oid.hex, pygit2.GIT_SORT_TIME) - ] + main_walker = repo_obj.walk( + orig_commit.oid.hex, pygit2.GIT_SORT_TIME) + branch_walker = repo_obj.walk( + repo_commit.oid.hex, pygit2.GIT_SORT_TIME) + main_commits = set() + branch_commits = set() - repo_commit = repo_obj[commitid] + while 1: + try: + com = main_walker.next() + main_commits.add(com.hex) + except StopIteration: + pass + try: + branch_commit = branch_walker.next() + except StopIteration: + branch_commit = None - for commit in repo_obj.walk( - repo_commit.oid.hex, pygit2.GIT_SORT_TIME): - if commit.oid.hex in master_commits: + branch_commits.add(branch_commit.oid.hex) + if main_commits.intersection(branch_commits): break - diff_commits.append(commit) + + diff_commits.append(branch_commit) if diff_commits: first_commit = repo_obj[diff_commits[-1].oid.hex]