Iterate commits and parents
This commit is contained in:
15
ugit/base.py
15
ugit/base.py
@@ -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