Create a flat list of commits to do from the tree

Walk the node tree and record the parents, then reverse the tree so we
can have the exact order in which to create git commits
This commit is contained in:
Stephan Kulow 2022-10-31 08:50:05 +01:00
parent 8a3db6c183
commit bfdade8ecf
5 changed files with 334 additions and 265 deletions

View File

@ -25,7 +25,7 @@ class DBRevision:
self._files = None
def short_string(self):
return f"Rev {self.project}/{self.package}/{self.rev}"
return f"{self.project}/{self.package}/{self.rev}"
def __str__(self):
return f"Rev {self.project}/{self.package}/{self.rev} Md5 {self.unexpanded_srcmd5} {self.commit_time} {self.userid} {self.request_number}"

View File

@ -10,7 +10,7 @@ from lib.history import History
from lib.obs import OBS
from lib.obs_revision import OBSRevision
from lib.proxy_sha256 import ProxySHA256, md5, sha256
from lib.tree_builder import AbstractWalker, TreeBuilder
from lib.tree_builder import AbstractWalker, TreeBuilder, TreeNode
from lib.user import User
@ -261,11 +261,80 @@ class Importer:
db = DB()
tree = TreeBuilder(db).build(self.package)
class ExportWalker(AbstractWalker):
def call(self, node, is_source):
pass
class FlatNode:
def __init__(self, branch, commit, parent1=None, parent2=None) -> None:
self.branch = branch
self.commit = commit
self.parent1 = parent1
self.parent2 = parent2
tree.walk(ExportWalker())
def __str__(self) -> str:
p1_str = ""
if self.parent1:
p1_str = f" p1:{self.parent1.short_string()}"
p2_str = ""
if self.parent2:
p2_str = f" p2:{self.parent2.short_string()}"
return f"{self.branch} c:{self.commit.short_string()}{p1_str}{p2_str}"
class FlatTreeWalker(AbstractWalker):
def __init__(self) -> None:
super().__init__()
self.flats = []
# remember the last merge point so we can know the parent of it for the root of the sources
self.last_merge = None
def add(self, branch, commit, parent1=None, parent2=None):
self.flats.append(FlatNode(branch, commit, parent1, parent2))
def handle_source_node(self, node) -> None:
if node.parent and node.parent.merged_into and False:
self.add("devel", node.revision, node.parent.merged_into.revision)
return
if node.parent:
self.add("devel", node.revision, node.parent.revision)
elif self.last_merge:
self.add("devel", node.revision, self.last_merge.parent.revision)
def call(self, node, is_source) -> None:
if is_source:
self.handle_source_node(node)
return
if not node.parent:
self.add("factory", node.revision)
return
if not node.merged:
self.add("factory", node.revision, node.parent.revision)
return
self.add(
"factory", node.revision, node.parent.revision, node.merged.revision
)
self.last_merge = node
ftw = FlatTreeWalker()
tree.walk(ftw)
for flat in reversed(ftw.flats):
self.commit_flat(flat)
def commit_flat(self, flat):
parents = []
self.git.checkout(flat.branch)
if flat.parent1:
parents.append(flat.parent1.git_commit)
if flat.parent2:
parents.append(flat.parent2.git_commit)
commit = self.git.commit(
f"OBS User {flat.commit.userid}",
"null@suse.de",
flat.commit.commit_time,
# TODO: Normalize better the commit message
f"{flat.commit.comment}\n\n{flat.commit}",
allow_empty=True,
parents=parents,
)
flat.commit.git_commit = commit
def import_into_db(self):
db = DB()

View File

@ -38,7 +38,7 @@ class TreeNode:
if node.merged:
source_node = node.merged
while source_node:
walker.call(node, True)
walker.call(source_node, True)
source_node = source_node.parent
if source_node and source_node.merged_into:
break

View File

@ -1,7 +1,7 @@
- commit: Rev openSUSE:Factory/clapper/3.0
- commit: openSUSE:Factory/clapper/3.0
merged:
- Rev multimedia:apps/clapper/9.0
- commit: Rev openSUSE:Factory/clapper/2.0
- multimedia:apps/clapper/9.0
- commit: openSUSE:Factory/clapper/2.0
merged:
- Rev multimedia:apps/clapper/7.0
- commit: Rev openSUSE:Factory/clapper/1.0
- multimedia:apps/clapper/7.0
- commit: openSUSE:Factory/clapper/1.0

View File

@ -1,300 +1,300 @@
- commit: Rev openSUSE:Factory/zsh/98.0
- commit: openSUSE:Factory/zsh/98.0
merged:
- Rev shells/zsh/236.0
- commit: Rev openSUSE:Factory/zsh/97.0
- shells/zsh/236.0
- commit: openSUSE:Factory/zsh/97.0
merged:
- Rev shells/zsh/234.0
- commit: Rev openSUSE:Factory/zsh/96.0
- shells/zsh/234.0
- commit: openSUSE:Factory/zsh/96.0
merged:
- Rev shells/zsh/232.0
- commit: Rev openSUSE:Factory/zsh/95.0
- shells/zsh/232.0
- commit: openSUSE:Factory/zsh/95.0
merged:
- Rev shells/zsh/230.0
- commit: Rev openSUSE:Factory/zsh/94.0
- shells/zsh/230.0
- commit: openSUSE:Factory/zsh/94.0
merged:
- Rev shells/zsh/228.0
- Rev shells/zsh/227.0
- commit: Rev openSUSE:Factory/zsh/93.0
- shells/zsh/228.0
- shells/zsh/227.0
- commit: openSUSE:Factory/zsh/93.0
merged:
- Rev shells/zsh/225.0
- Rev shells/zsh/224.0
- Rev shells/zsh/223.0
- commit: Rev openSUSE:Factory/zsh/92.0
- shells/zsh/225.0
- shells/zsh/224.0
- shells/zsh/223.0
- commit: openSUSE:Factory/zsh/92.0
merged:
- Rev shells/zsh/221.0
- commit: Rev openSUSE:Factory/zsh/91.0
- shells/zsh/221.0
- commit: openSUSE:Factory/zsh/91.0
merged:
- Rev shells/zsh/219.0
- commit: Rev openSUSE:Factory/zsh/90.0
- shells/zsh/219.0
- commit: openSUSE:Factory/zsh/90.0
merged:
- Rev shells/zsh/217.0
- commit: Rev openSUSE:Factory/zsh/89.0
- shells/zsh/217.0
- commit: openSUSE:Factory/zsh/89.0
merged:
- Rev shells/zsh/215.0
- Rev shells/zsh/214.0
- commit: Rev openSUSE:Factory/zsh/88.0
- shells/zsh/215.0
- shells/zsh/214.0
- commit: openSUSE:Factory/zsh/88.0
merged:
- Rev shells/zsh/212.0
- commit: Rev openSUSE:Factory/zsh/87.0
- shells/zsh/212.0
- commit: openSUSE:Factory/zsh/87.0
merged:
- Rev shells/zsh/210.0
- Rev shells/zsh/209.0
- Rev shells/zsh/208.0
- Rev shells/zsh/207.0
- commit: Rev openSUSE:Factory/zsh/86.0
- shells/zsh/210.0
- shells/zsh/209.0
- shells/zsh/208.0
- shells/zsh/207.0
- commit: openSUSE:Factory/zsh/86.0
merged:
- Rev shells/zsh/205.0
- Rev shells/zsh/204.0
- commit: Rev openSUSE:Factory/zsh/85.0
- shells/zsh/205.0
- shells/zsh/204.0
- commit: openSUSE:Factory/zsh/85.0
merged:
- Rev shells/zsh/202.0
- Rev shells/zsh/201.0
- commit: Rev openSUSE:Factory/zsh/84.0
- shells/zsh/202.0
- shells/zsh/201.0
- commit: openSUSE:Factory/zsh/84.0
merged:
- Rev shells/zsh/199.0
- Rev shells/zsh/198.0
- Rev shells/zsh/197.0
- commit: Rev openSUSE:Factory/zsh/83.0
- shells/zsh/199.0
- shells/zsh/198.0
- shells/zsh/197.0
- commit: openSUSE:Factory/zsh/83.0
merged:
- Rev shells/zsh/195.0
- Rev shells/zsh/194.0
- Rev shells/zsh/193.0
- Rev shells/zsh/192.0
- Rev shells/zsh/191.0
- commit: Rev openSUSE:Factory/zsh/82.0
- shells/zsh/195.0
- shells/zsh/194.0
- shells/zsh/193.0
- shells/zsh/192.0
- shells/zsh/191.0
- commit: openSUSE:Factory/zsh/82.0
merged:
- Rev shells/zsh/189.0
- commit: Rev openSUSE:Factory/zsh/81.0
- shells/zsh/189.0
- commit: openSUSE:Factory/zsh/81.0
merged:
- Rev shells/zsh/187.0
- Rev shells/zsh/186.0
- commit: Rev openSUSE:Factory/zsh/80.0
- shells/zsh/187.0
- shells/zsh/186.0
- commit: openSUSE:Factory/zsh/80.0
merged:
- Rev shells/zsh/184.0
- commit: Rev openSUSE:Factory/zsh/79.0
- shells/zsh/184.0
- commit: openSUSE:Factory/zsh/79.0
merged:
- Rev shells/zsh/182.0
- commit: Rev openSUSE:Factory/zsh/78.0
- shells/zsh/182.0
- commit: openSUSE:Factory/zsh/78.0
merged:
- Rev shells/zsh/180.0
- commit: Rev openSUSE:Factory/zsh/77.0
- shells/zsh/180.0
- commit: openSUSE:Factory/zsh/77.0
merged:
- Rev shells/zsh/178.0
- Rev shells/zsh/177.0
- commit: Rev openSUSE:Factory/zsh/76.0
- shells/zsh/178.0
- shells/zsh/177.0
- commit: openSUSE:Factory/zsh/76.0
merged:
- Rev shells/zsh/175.0
- commit: Rev openSUSE:Factory/zsh/75.0
- shells/zsh/175.0
- commit: openSUSE:Factory/zsh/75.0
merged:
- Rev shells/zsh/173.0
- commit: Rev openSUSE:Factory/zsh/74.0
- shells/zsh/173.0
- commit: openSUSE:Factory/zsh/74.0
merged:
- Rev shells/zsh/171.0
- Rev shells/zsh/170.0
- commit: Rev openSUSE:Factory/zsh/73.0
- shells/zsh/171.0
- shells/zsh/170.0
- commit: openSUSE:Factory/zsh/73.0
merged:
- Rev shells/zsh/168.0
- commit: Rev openSUSE:Factory/zsh/72.0
- shells/zsh/168.0
- commit: openSUSE:Factory/zsh/72.0
merged:
- Rev shells/zsh/166.0
- commit: Rev openSUSE:Factory/zsh/71.0
- shells/zsh/166.0
- commit: openSUSE:Factory/zsh/71.0
merged:
- Rev shells/zsh/164.0
- commit: Rev openSUSE:Factory/zsh/70.0
- shells/zsh/164.0
- commit: openSUSE:Factory/zsh/70.0
merged:
- Rev shells/zsh/162.0
- commit: Rev openSUSE:Factory/zsh/69.0
- shells/zsh/162.0
- commit: openSUSE:Factory/zsh/69.0
merged:
- Rev shells/zsh/160.0
- Rev shells/zsh/159.0
- Rev shells/zsh/158.0
- commit: Rev openSUSE:Factory/zsh/68.0
- shells/zsh/160.0
- shells/zsh/159.0
- shells/zsh/158.0
- commit: openSUSE:Factory/zsh/68.0
merged:
- Rev shells/zsh/156.0
- commit: Rev openSUSE:Factory/zsh/67.0
- shells/zsh/156.0
- commit: openSUSE:Factory/zsh/67.0
merged:
- Rev shells/zsh/154.0
- Rev shells/zsh/153.0
- commit: Rev openSUSE:Factory/zsh/66.0
- shells/zsh/154.0
- shells/zsh/153.0
- commit: openSUSE:Factory/zsh/66.0
merged:
- Rev shells/zsh/151.0
- Rev shells/zsh/150.0
- commit: Rev openSUSE:Factory/zsh/65.0
- shells/zsh/151.0
- shells/zsh/150.0
- commit: openSUSE:Factory/zsh/65.0
merged:
- Rev shells/zsh/148.0
- commit: Rev openSUSE:Factory/zsh/64.0
- shells/zsh/148.0
- commit: openSUSE:Factory/zsh/64.0
merged:
- Rev shells/zsh/146.0
- Rev shells/zsh/145.0
- Rev shells/zsh/144.0
- commit: Rev openSUSE:Factory/zsh/63.0
- shells/zsh/146.0
- shells/zsh/145.0
- shells/zsh/144.0
- commit: openSUSE:Factory/zsh/63.0
merged:
- Rev shells/zsh/142.0
- commit: Rev openSUSE:Factory/zsh/62.0
- shells/zsh/142.0
- commit: openSUSE:Factory/zsh/62.0
merged:
- Rev shells/zsh/140.0
- commit: Rev openSUSE:Factory/zsh/61.0
- shells/zsh/140.0
- commit: openSUSE:Factory/zsh/61.0
merged:
- Rev shells/zsh/138.0
- Rev shells/zsh/137.0
- commit: Rev openSUSE:Factory/zsh/60.0
- shells/zsh/138.0
- shells/zsh/137.0
- commit: openSUSE:Factory/zsh/60.0
merged:
- Rev shells/zsh/135.0
- commit: Rev openSUSE:Factory/zsh/59.0
- shells/zsh/135.0
- commit: openSUSE:Factory/zsh/59.0
merged:
- Rev shells/zsh/133.0
- commit: Rev openSUSE:Factory/zsh/57.0
- shells/zsh/133.0
- commit: openSUSE:Factory/zsh/57.0
merged:
- Rev shells/zsh/131.0
- commit: Rev openSUSE:Factory/zsh/56.0
- shells/zsh/131.0
- commit: openSUSE:Factory/zsh/56.0
merged:
- Rev shells/zsh/129.0
- commit: Rev openSUSE:Factory/zsh/55.0
- shells/zsh/129.0
- commit: openSUSE:Factory/zsh/55.0
merged:
- Rev shells/zsh/127.0
- commit: Rev openSUSE:Factory/zsh/54.0
- shells/zsh/127.0
- commit: openSUSE:Factory/zsh/54.0
merged:
- Rev shells/zsh/125.0
- commit: Rev openSUSE:Factory/zsh/53.0
merged:
- Rev shells/zsh/123.0
- commit: Rev openSUSE:Factory/zsh/51.0
- shells/zsh/125.0
- commit: openSUSE:Factory/zsh/53.0
merged:
- shells/zsh/123.0
- commit: openSUSE:Factory/zsh/51.0
merged:
- Rev shells/zsh/121.0
- commit: Rev openSUSE:Factory/zsh/50.0
- shells/zsh/121.0
- commit: openSUSE:Factory/zsh/50.0
merged:
- Rev shells/zsh/119.0
- commit: Rev openSUSE:Factory/zsh/49.0
- shells/zsh/119.0
- commit: openSUSE:Factory/zsh/49.0
merged:
- Rev shells/zsh/117.0
- commit: Rev openSUSE:Factory/zsh/48.0
merged:
- Rev shells/zsh/115.0
- commit: Rev openSUSE:Factory/zsh/46.0
merged:
- Rev shells/zsh/113.0
- commit: Rev openSUSE:Factory/zsh/45.0
merged:
- Rev shells/zsh/111.0
- commit: Rev openSUSE:Factory/zsh/44.0
merged:
- Rev shells/zsh/109.0
- commit: Rev openSUSE:Factory/zsh/43.0
merged:
- Rev shells/zsh/107.0
- commit: Rev openSUSE:Factory/zsh/42.0
merged:
- Rev shells/zsh/105.0
- commit: Rev openSUSE:Factory/zsh/41.0
merged:
- Rev shells/zsh/103.0
- Rev shells/zsh/102.0
- commit: Rev openSUSE:Factory/zsh/39.0
merged:
- Rev shells/zsh/100.0
- commit: Rev openSUSE:Factory/zsh/38.0
merged:
- Rev shells/zsh/98.0
- commit: Rev openSUSE:Factory/zsh/37.0
merged:
- Rev shells/zsh/95.0
- Rev shells/zsh/94.0
- Rev shells/zsh/91.0
- commit: Rev openSUSE:Factory/zsh/36.0
merged:
- Rev shells/zsh/90.0
- Rev shells/zsh/89.0
- Rev shells/zsh/88.0
- Rev shells/zsh/87.0
- commit: Rev openSUSE:Factory/zsh/35.0
merged:
- Rev shells/zsh/84.0
- Rev shells/zsh/83.0
- Rev shells/zsh/82.0
- Rev shells/zsh/81.0
- Rev shells/zsh/80.0
- commit: Rev openSUSE:Factory/zsh/34.0
merged:
- Rev shells/zsh/77.0
- Rev shells/zsh/76.032
- commit: Rev openSUSE:Factory/zsh/32.0
- commit: Rev openSUSE:Factory/zsh/31.0
merged:
- Rev shells/zsh/75.0
- Rev shells/zsh/74.0
- Rev shells/zsh/73.0
- Rev shells/zsh/72.03
- commit: Rev openSUSE:Factory/zsh/30.0
- commit: Rev openSUSE:Factory/zsh/29.0
merged:
- Rev shells/zsh/71.0
- commit: Rev openSUSE:Factory/zsh/28.0
merged:
- Rev shells/zsh/69.0
- Rev shells/zsh/68.0
- Rev shells/zsh/67.027
- commit: Rev openSUSE:Factory/zsh/27.0
- commit: Rev openSUSE:Factory/zsh/26.0
merged:
- Rev shells/zsh/66.0
- Rev shells/zsh/65.0
- Rev shells/zsh/64.0
- Rev shells/zsh/63.0
- Rev shells/zsh/62.0
- Rev shells/zsh/61.0
- Rev shells/zsh/60.0
- Rev shells/zsh/59.0
- Rev shells/zsh/58.0
- Rev shells/zsh/57.0
- Rev shells/zsh/56.0
- Rev shells/zsh/55.0
- Rev shells/zsh/54.0
- Rev shells/zsh/53.0
- Rev shells/zsh/52.0
- Rev shells/zsh/51.0
- Rev shells/zsh/50.0
- Rev shells/zsh/49.0
- Rev shells/zsh/48.0
- Rev shells/zsh/47.0
- Rev shells/zsh/46.025
- commit: Rev openSUSE:Factory/zsh/25.0
- commit: Rev openSUSE:Factory/zsh/24.0
merged:
- Rev shells/zsh/45.0
- Rev shells/zsh/44.0
- Rev shells/zsh/43.023
- commit: Rev openSUSE:Factory/zsh/23.0
- commit: Rev openSUSE:Factory/zsh/22.0
merged:
- Rev shells/zsh/42.0
- Rev shells/zsh/41.035
- commit: Rev openSUSE:Factory/zsh/18.0
- commit: Rev openSUSE:Factory/zsh/17.0
merged:
- Rev shells/zsh/41.017
- Rev shells/zsh/41.0
- Rev shells/zsh/40.0
- Rev shells/zsh/39.0
- Rev shells/zsh/38.0
- Rev shells/zsh/37.0
- commit: Rev openSUSE:Factory/zsh/16.0
- commit: Rev openSUSE:Factory/zsh/14.0
merged:
- Rev shells/zsh/36.014
- Rev shells/zsh/36.0
- Rev shells/zsh/35.0
- commit: Rev openSUSE:Factory/zsh/13.0
merged:
- Rev shells/zsh/34.0
- commit: Rev openSUSE:Factory/zsh/12.0
- commit: Rev openSUSE:Factory/zsh/11.0
- commit: Rev openSUSE:Factory/zsh/10.0
- commit: Rev openSUSE:Factory/zsh/9.0
- commit: Rev openSUSE:Factory/zsh/8.0
- commit: Rev openSUSE:Factory/zsh/7.0
- commit: Rev openSUSE:Factory/zsh/6.0
- commit: Rev openSUSE:Factory/zsh/5.0
- commit: Rev openSUSE:Factory/zsh/4.0
- commit: Rev openSUSE:Factory/zsh/3.0
- commit: Rev openSUSE:Factory/zsh/2.0
- commit: Rev openSUSE:Factory/zsh/1.0
- shells/zsh/117.0
- commit: openSUSE:Factory/zsh/48.0
merged:
- shells/zsh/115.0
- commit: openSUSE:Factory/zsh/46.0
merged:
- shells/zsh/113.0
- commit: openSUSE:Factory/zsh/45.0
merged:
- shells/zsh/111.0
- commit: openSUSE:Factory/zsh/44.0
merged:
- shells/zsh/109.0
- commit: openSUSE:Factory/zsh/43.0
merged:
- shells/zsh/107.0
- commit: openSUSE:Factory/zsh/42.0
merged:
- shells/zsh/105.0
- commit: openSUSE:Factory/zsh/41.0
merged:
- shells/zsh/103.0
- shells/zsh/102.0
- commit: openSUSE:Factory/zsh/39.0
merged:
- shells/zsh/100.0
- commit: openSUSE:Factory/zsh/38.0
merged:
- shells/zsh/98.0
- commit: openSUSE:Factory/zsh/37.0
merged:
- shells/zsh/95.0
- shells/zsh/94.0
- shells/zsh/91.0
- commit: openSUSE:Factory/zsh/36.0
merged:
- shells/zsh/90.0
- shells/zsh/89.0
- shells/zsh/88.0
- shells/zsh/87.0
- commit: openSUSE:Factory/zsh/35.0
merged:
- shells/zsh/84.0
- shells/zsh/83.0
- shells/zsh/82.0
- shells/zsh/81.0
- shells/zsh/80.0
- commit: openSUSE:Factory/zsh/34.0
merged:
- shells/zsh/77.0
- shells/zsh/76.032
- commit: openSUSE:Factory/zsh/32.0
- commit: openSUSE:Factory/zsh/31.0
merged:
- shells/zsh/75.0
- shells/zsh/74.0
- shells/zsh/73.0
- shells/zsh/72.03
- commit: openSUSE:Factory/zsh/30.0
- commit: openSUSE:Factory/zsh/29.0
merged:
- shells/zsh/71.0
- commit: openSUSE:Factory/zsh/28.0
merged:
- shells/zsh/69.0
- shells/zsh/68.0
- shells/zsh/67.027
- commit: openSUSE:Factory/zsh/27.0
- commit: openSUSE:Factory/zsh/26.0
merged:
- shells/zsh/66.0
- shells/zsh/65.0
- shells/zsh/64.0
- shells/zsh/63.0
- shells/zsh/62.0
- shells/zsh/61.0
- shells/zsh/60.0
- shells/zsh/59.0
- shells/zsh/58.0
- shells/zsh/57.0
- shells/zsh/56.0
- shells/zsh/55.0
- shells/zsh/54.0
- shells/zsh/53.0
- shells/zsh/52.0
- shells/zsh/51.0
- shells/zsh/50.0
- shells/zsh/49.0
- shells/zsh/48.0
- shells/zsh/47.0
- shells/zsh/46.025
- commit: openSUSE:Factory/zsh/25.0
- commit: openSUSE:Factory/zsh/24.0
merged:
- shells/zsh/45.0
- shells/zsh/44.0
- shells/zsh/43.023
- commit: openSUSE:Factory/zsh/23.0
- commit: openSUSE:Factory/zsh/22.0
merged:
- shells/zsh/42.0
- shells/zsh/41.035
- commit: openSUSE:Factory/zsh/18.0
- commit: openSUSE:Factory/zsh/17.0
merged:
- shells/zsh/41.017
- shells/zsh/41.0
- shells/zsh/40.0
- shells/zsh/39.0
- shells/zsh/38.0
- shells/zsh/37.0
- commit: openSUSE:Factory/zsh/16.0
- commit: openSUSE:Factory/zsh/14.0
merged:
- shells/zsh/36.014
- shells/zsh/36.0
- shells/zsh/35.0
- commit: openSUSE:Factory/zsh/13.0
merged:
- shells/zsh/34.0
- commit: openSUSE:Factory/zsh/12.0
- commit: openSUSE:Factory/zsh/11.0
- commit: openSUSE:Factory/zsh/10.0
- commit: openSUSE:Factory/zsh/9.0
- commit: openSUSE:Factory/zsh/8.0
- commit: openSUSE:Factory/zsh/7.0
- commit: openSUSE:Factory/zsh/6.0
- commit: openSUSE:Factory/zsh/5.0
- commit: openSUSE:Factory/zsh/4.0
- commit: openSUSE:Factory/zsh/3.0
- commit: openSUSE:Factory/zsh/2.0
- commit: openSUSE:Factory/zsh/1.0