Merge "Handle explicit merges"

This commit is contained in:
Zuul 2018-04-27 17:55:43 +00:00 committed by Gerrit Code Review
commit 70c844ba9d
2 changed files with 45 additions and 1 deletions

View File

@ -128,7 +128,9 @@ class Searcher(GitMixin):
self.log.debug("Merge base is not the same as root merge base")
return None, [], None
other_parents = [p.hexsha for p in mergecommit.parents if p != parent]
other_parents = set(
p.hexsha for p in mergecommit.parents if p != parent
)
self.log.debug("Merge base is same: other_parents: %s", other_parents)
# if the merge base of the parent against any of the other parents
@ -145,6 +147,11 @@ class Searcher(GitMixin):
if exclude_commits:
return None, [], exclude_commits
# handle case where merges are always created in GitHub even when
# not needed.
if other_parents.issubset(ancestry_commits):
return None, [], []
# otherwise looking at the previous import merge commit and the parent
# from the previous import branch, so exclude all other parents.
return mergecommit, ["^%s" % ip for ip in other_parents], None

View File

@ -0,0 +1,37 @@
- desc: |
Construct a repo layout where using a complex layout where no
previous import from upstream having been completed, test that if a
change has been explicitly merged (common with GitHub PR's) without
it being necessary, then the searcher will correct include the
change and not detect it as a possible import merge
will the searcher correctly include 'O' below even though there was
no need for a merge 'D' to be created.
Repository layout being tested
O
/ \
B---C---D---G master
/
A---E---F---L---M upstream/master
tree:
- [A, []]
- [B, [A]]
- [C, [B]]
- [O, [C]]
- [D, [C, =O]]
- [E, [A]]
- [F, [E]]
- [G, [D]]
- [L, [F]]
- [M, [L]]
branches:
head: [master, G]
upstream: [upstream/master, M]
expected-changes: [B, C, O, D, G]