Iterate commits and parents
This commit is contained in:
parent
7fbf6640f6
commit
d53322c256
15
ugit/base.py
15
ugit/base.py
@ -129,6 +129,21 @@ def get_commit(oid):
|
||||
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):
|
||||
if name == "@":
|
||||
name = "HEAD"
|
||||
|
Loading…
Reference in New Issue
Block a user