Handle explicit merges
GitHub projects commonly include explicit merges even when not necessary, make sure to skip these as candidates of a previous import. After checking the other parents of an import to see if any were an empty merge of an obsolete commit, test whether the parents are themselves a subset of the ancestry commits and ignore should this be true. Change-Id: I8b8f0b0689301cedb8b4352c3decb569c94a0e33
This commit is contained in:
parent
0c33431d2e
commit
350be21af3
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
Loading…
Reference in New Issue