Find better import merge commit candidate
Continue checking until the last possible candidate has been inspected in case we encountered a merge commit that looks a lot like an import merge commit does. It is possible for a merge to occur where the commit brought in does not contribute anything to the resulting tree. In such cases the merge commit will appear TREESAME to the previous state of the branch, and will be mistaken to be an import merge. Ensure if there is an additional merge commit to be considered that it is also checked. Change-Id: If5694506b59e1288e23aecbe6e0bf8297574c72a Related-Bug: #1648029
This commit is contained in:
parent
7cffd9dc0b
commit
0100a7e1d5
|
@ -155,12 +155,12 @@ class Searcher(GitMixin):
|
|||
topo_order=True,
|
||||
ancestry_path=True, merges=True))
|
||||
extra_args = []
|
||||
previous_import = False
|
||||
previous_import = None
|
||||
for mergecommit, parent in ((mc, p)
|
||||
for mc in merge_list
|
||||
for p in mc.parents):
|
||||
# inspect each
|
||||
previous_import, ignores = self._check_merge_is_previous(
|
||||
previous_import_candidate, ignores = self._check_merge_is_previous(
|
||||
mergecommit, parent, merge_list[-1])
|
||||
|
||||
if ignores:
|
||||
|
@ -171,13 +171,20 @@ class Searcher(GitMixin):
|
|||
""", "\n ".join(ignores))
|
||||
extra_args.extend(ignores)
|
||||
|
||||
if previous_import:
|
||||
if previous_import_candidate:
|
||||
previous_import = previous_import_candidate
|
||||
self.log.info(
|
||||
"""
|
||||
Found the previous import merge:
|
||||
%s
|
||||
""", mergecommit)
|
||||
break
|
||||
""", previous_import)
|
||||
|
||||
if previous_import:
|
||||
self.log.info(
|
||||
"""
|
||||
Found possible previous import merge:
|
||||
%s
|
||||
""", previous_import)
|
||||
|
||||
# walk the tree and find all commits that lie in the path between the
|
||||
# commit found by find() and head of the branch in two steps, to
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
- desc: |
|
||||
Using a complex repo layout containing a previous import from upstream,
|
||||
test a change that was created from the target branch before the previous
|
||||
import but only merged after the import, and furthermore did not introduce
|
||||
any changes to the branch. It should not be incorrectly detected as the
|
||||
previous import merge.
|
||||
|
||||
i.e. will the searcher ignore 'I' even though it is treesame to 'H',
|
||||
and instead correctly detect 'H' as the previous import given the
|
||||
diagram below. Additionally will it exclude 'O' as not contributing
|
||||
anything to the final state.
|
||||
|
||||
Repository layout being tested
|
||||
|
||||
O------------
|
||||
/ \
|
||||
B---C---D---G---H---I---J---K master
|
||||
/ /
|
||||
/ B1--C1--D1 import/next
|
||||
/ /
|
||||
A---E---F---L---M upstream/master
|
||||
|
||||
|
||||
tree:
|
||||
- [A, []]
|
||||
- [B, [A]]
|
||||
- [C, [B]]
|
||||
- [O, [C]]
|
||||
- [D, [C]]
|
||||
- [E, [A]]
|
||||
- [F, [E]]
|
||||
- [G, [D]]
|
||||
- [B1, [F]]
|
||||
- [C1, [B1]]
|
||||
- [D1, [C1]]
|
||||
- [H, [G, =D1]]
|
||||
# next node definition ensures I is TREESAME to H
|
||||
- [I, [=H, O]]
|
||||
- [J, [I]]
|
||||
- [K, [J]]
|
||||
- [L, [F]]
|
||||
- [M, [L]]
|
||||
|
||||
branches:
|
||||
head: [master, K]
|
||||
upstream: [upstream/master, M]
|
||||
|
||||
expected-changes: [B1, C1, D1, H, I, J, K]
|
Loading…
Reference in New Issue