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

hg2git: implement a method to initialize _dirs from a Git commit

Upcoming patches will start incrementally exporting from a particular commit
instead of from null. This function will be used for that..
parent 5e74edb7
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
import stat
import dulwich.objects as dulobjs
from dulwich import diff_tree
import mercurial.node
import mercurial.context
......@@ -72,6 +73,21 @@
# blob calculation.
self._blob_cache = {}
def _init_dirs(self, store, commit):
"""Initialize self._dirs for a Git object store and commit."""
self._dirs = {}
if commit is None:
return
dirkind = stat.S_IFDIR
# depth-first order, chosen arbitrarily
todo = [('', store[commit.tree])]
while todo:
path, tree = todo.pop()
self._dirs[path] = tree
for entry in tree.iteritems():
if entry.mode == dirkind:
todo.append((path + '/' + entry.path, store[entry.sha]))
@property
def root_tree_sha(self):
"""The SHA-1 of the root Git tree.
......
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