Iterate commits and parents
This commit is contained in:
1 parent
7fbf6640f6
commit
d53322c256
1 file changed
+15
@@ -129,6 +129,21 @@ def get_commit(oid):
|
|||||||
return Commit(tree=tree, parent=parent, message=message)
|
return Commit(tree=tree, parent=parent, message=message)
|
||||||
|
|
||||||
|
|
||||||
|
def iter_commits_and_parents(oids):
|
||||||
|
oids = set(oids)
|
||||||
|
visited = set()
|
||||||
|
|
||||||
|
while oids:
|
||||||
|
oid = oids.pop()
|
||||||
|
if not oid or oid in visited:
|
||||||
|
continue
|
||||||
|
visited.add(oid)
|
||||||
|
yield oid
|
||||||
|
|
||||||
|
commit = get_commit(oid)
|
||||||
|
oids.add(commit.parent)
|
||||||
|
|
||||||
|
|
||||||
def get_oid(name):
|
def get_oid(name):
|
||||||
if name == "@":
|
if name == "@":
|
||||||
name = "HEAD"
|
name = "HEAD"
|
||||||
|
|||||||
Reference in new issue
Block a user