git2hg.find_incoming: move graph traversal into a function

This is preparation for upcoming changes to find_incoming that will allow it to
import certain Git branches as Mercurial named branches.
This commit is contained in:
Siddharth Agarwal 2014-10-15 14:21:09 -07:00
parent 39849eaa29
commit e38779118a

View File

@ -36,10 +36,11 @@ def find_incoming(git_object_store, git_map, refs):
todo.sort(key=commitdate, reverse=True)
return todo
todo = get_heads(refs)
def get_unseen_commits(todo):
'''get all unseen commits reachable from todo in topological order
# traverse the heads getting a list of all the unique commits in
# topological order
'unseen' means not reachable from the done set and not in the git map.
Mutates todo and the done set in the process.'''
commits = []
while todo:
sha = todo[-1]
@ -64,6 +65,11 @@ def find_incoming(git_object_store, git_map, refs):
done.add(sha)
todo.pop()
return commits
todo = get_heads(refs)
commits = get_unseen_commits(todo)
return GitIncomingResult(commits, commit_cache)
class GitIncomingResult(object):