Skip to content
Snippets Groups Projects
Commit 388944fc authored by Siddharth Agarwal's avatar Siddharth Agarwal
Browse files

git2hg.find_incoming: move head-finding code 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.
parent 342b58e4
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,6 @@
git_map is a map with keys being Git commits that have already been imported
refs is a map of refs to SHAs that we're interested in.'''
todo = []
done = set()
commit_cache = {}
......@@ -13,22 +12,8 @@
done = set()
commit_cache = {}
# get a list of all the head shas
seenheads = set()
for sha in refs.itervalues():
# refs could contain refs on the server that we haven't pulled down the
# objects for
if sha in git_object_store:
obj = git_object_store[sha]
while isinstance(obj, Tag):
obj_type, sha = obj.object
obj = git_object_store[sha]
if isinstance (obj, Commit) and sha not in seenheads:
seenheads.add(sha)
todo.append(sha)
# sort by commit date
def commitdate(sha):
obj = git_object_store[sha]
return obj.commit_time-obj.commit_timezone
......@@ -30,9 +15,28 @@
# sort by commit date
def commitdate(sha):
obj = git_object_store[sha]
return obj.commit_time-obj.commit_timezone
todo.sort(key=commitdate, reverse=True)
# get a list of all the head shas
def get_heads(refs):
todo = []
seenheads = set()
for sha in refs.itervalues():
# refs could contain refs on the server that we haven't pulled down
# the objects for
if sha in git_object_store:
obj = git_object_store[sha]
while isinstance(obj, Tag):
obj_type, sha = obj.object
obj = git_object_store[sha]
if isinstance(obj, Commit) and sha not in seenheads:
seenheads.add(sha)
todo.append(sha)
todo.sort(key=commitdate, reverse=True)
return todo
todo = get_heads(refs)
# traverse the heads getting a list of all the unique commits in
# topological order
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment