Ignore merge point candidates that create crosses
In OBS you can create submit requests for revisions that are behind the last merge point, in git you can't - so we ignore them. Fixes #14
This commit is contained in:
parent
ef7755c771
commit
f2019db8ff
@ -31,6 +31,7 @@ class DBRevision:
|
||||
self.rev = float(self.rev)
|
||||
self._files = None
|
||||
self.db = db
|
||||
self.git_commit = None
|
||||
|
||||
def short_string(self):
|
||||
return f"{self.project}/{self.package}/{self.rev}"
|
||||
|
@ -107,10 +107,12 @@ class GitExporter:
|
||||
if flat.parent1:
|
||||
if not self.branch_fits_parent1(flat, branch_state):
|
||||
logging.info(f"Reset {flat.branch} onto {flat.parent1.short_string()}")
|
||||
assert flat.parent1.git_commit
|
||||
self.git.set_branch_head(flat.branch, flat.parent1.git_commit)
|
||||
self.git.checkout(flat.branch)
|
||||
parents.append(flat.parent1.git_commit)
|
||||
if flat.parent2:
|
||||
assert flat.parent2.git_commit
|
||||
parents.append(flat.parent2.git_commit)
|
||||
|
||||
# Overwrite ".gitattributes" with the
|
||||
|
@ -104,14 +104,23 @@ class TreeBuilder:
|
||||
"""For a given revision in the target, find the node in the source chain
|
||||
that matches the files"""
|
||||
node = source_chain
|
||||
candidates = []
|
||||
while node:
|
||||
# exclude reverts happening after the merge
|
||||
if (
|
||||
node.revision.commit_time <= revision.commit_time
|
||||
and node.revision.files_hash == revision.files_hash
|
||||
):
|
||||
return node
|
||||
candidates.append(node)
|
||||
if node.merged_into:
|
||||
# we can't have candidates that are crossing previous merges
|
||||
# see https://gitea.opensuse.org/importers/git-importer/issues/14
|
||||
candidates = []
|
||||
node = node.parent
|
||||
if candidates:
|
||||
# the assert is here to see if we have more hot cases
|
||||
assert len(candidates) == 1
|
||||
return candidates[0]
|
||||
|
||||
def add_merge_points(self, factory_revisions):
|
||||
"""For all target revisions that accepted a request, look up the merge
|
||||
|
9
tests/fixtures/firewalld-expected-list.yaml
vendored
9
tests/fixtures/firewalld-expected-list.yaml
vendored
@ -44,8 +44,7 @@
|
||||
- factory c:openSUSE:Factory/firewalld/53.0 p1:openSUSE:Factory/firewalld/52.0 p2:security:netfilter/firewalld/107.0
|
||||
- devel c:security:netfilter/firewalld/107.0 p1:security:netfilter/firewalld/106.0
|
||||
- factory c:openSUSE:Factory/firewalld/52.0 p1:openSUSE:Factory/firewalld/51.0
|
||||
- factory c:openSUSE:Factory/firewalld/51.0 p1:openSUSE:Factory/firewalld/50.0 p2:security:netfilter/firewalld/107.0
|
||||
- devel c:security:netfilter/firewalld/107.0 p1:security:netfilter/firewalld/106.0
|
||||
- factory c:openSUSE:Factory/firewalld/51.0 p1:openSUSE:Factory/firewalld/50.0
|
||||
- factory c:openSUSE:Factory/firewalld/50.0 p1:openSUSE:Factory/firewalld/49.0 p2:security:netfilter/firewalld/106.0
|
||||
- devel c:security:netfilter/firewalld/106.0 p1:security:netfilter/firewalld/105.0
|
||||
- factory c:openSUSE:Factory/firewalld/49.0 p1:openSUSE:Factory/firewalld/48.0 p2:security:netfilter/firewalld/105.0
|
||||
@ -89,13 +88,13 @@
|
||||
- devel c:security:netfilter/firewalld/82.0 p1:security:netfilter/firewalld/81.0
|
||||
- devel c:security:netfilter/firewalld/81.0 p1:security:netfilter/firewalld/80.0
|
||||
- devel c:security:netfilter/firewalld/80.0 p1:security:netfilter/firewalld/79.0
|
||||
- devel c:security:netfilter/firewalld/79.0 p1:security:netfilter/firewalld/78.0
|
||||
- devel c:security:netfilter/firewalld/78.0 p1:security:netfilter/firewalld/77.0
|
||||
- factory c:openSUSE:Factory/firewalld/34.0 p1:openSUSE:Factory/firewalld/33.0 p2:security:netfilter/firewalld/77.0
|
||||
- devel c:security:netfilter/firewalld/77.0 p1:security:netfilter/firewalld/76.0
|
||||
- devel c:security:netfilter/firewalld/76.0 p1:security:netfilter/firewalld/75.0
|
||||
- devel c:security:netfilter/firewalld/75.0 p1:security:netfilter/firewalld/74.0
|
||||
- factory c:openSUSE:Factory/firewalld/33.0 p1:openSUSE:Factory/firewalld/32.0 p2:security:netfilter/firewalld/79.0
|
||||
- devel c:security:netfilter/firewalld/79.0 p1:security:netfilter/firewalld/78.0
|
||||
- devel c:security:netfilter/firewalld/78.0 p1:security:netfilter/firewalld/77.0
|
||||
- factory c:openSUSE:Factory/firewalld/33.0 p1:openSUSE:Factory/firewalld/32.0
|
||||
- factory c:openSUSE:Factory/firewalld/32.0 p1:openSUSE:Factory/firewalld/31.0 p2:security:netfilter/firewalld/74.0
|
||||
- devel c:security:netfilter/firewalld/74.0 p1:security:netfilter/firewalld/71.0
|
||||
- factory c:openSUSE:Factory/firewalld/31.0 p1:openSUSE:Factory/firewalld/30.0
|
||||
|
7
tests/fixtures/firewalld-expected-tree.yaml
vendored
7
tests/fixtures/firewalld-expected-tree.yaml
vendored
@ -65,8 +65,6 @@
|
||||
- security:netfilter/firewalld/107.0
|
||||
- commit: openSUSE:Factory/firewalld/52.0
|
||||
- commit: openSUSE:Factory/firewalld/51.0
|
||||
merged:
|
||||
- security:netfilter/firewalld/107.0
|
||||
- commit: openSUSE:Factory/firewalld/50.0
|
||||
merged:
|
||||
- security:netfilter/firewalld/106.0
|
||||
@ -126,15 +124,14 @@
|
||||
- security:netfilter/firewalld/82.0
|
||||
- security:netfilter/firewalld/81.0
|
||||
- security:netfilter/firewalld/80.0
|
||||
- security:netfilter/firewalld/79.0
|
||||
- security:netfilter/firewalld/78.0
|
||||
- commit: openSUSE:Factory/firewalld/34.0
|
||||
merged:
|
||||
- security:netfilter/firewalld/77.0
|
||||
- security:netfilter/firewalld/76.0
|
||||
- security:netfilter/firewalld/75.0
|
||||
- commit: openSUSE:Factory/firewalld/33.0
|
||||
merged:
|
||||
- security:netfilter/firewalld/79.0
|
||||
- security:netfilter/firewalld/78.0
|
||||
- commit: openSUSE:Factory/firewalld/32.0
|
||||
merged:
|
||||
- security:netfilter/firewalld/74.0
|
||||
|
@ -71,5 +71,6 @@ class TestTreeMethods(unittest.TestCase):
|
||||
def test_firewalld_tree(self):
|
||||
self.verify_package("firewalld")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user