Mercurial > hg-git
changeset 175:cee0473e67ca
remove profiling code and cache all trees more effectively
author | Scott Chacon <schacon@gmail.com> |
---|---|
date | Wed, 03 Jun 2009 13:29:28 -0700 |
parents | 4286209da98e |
children | 814499406d4c |
files | __init__.py dulwich/repo.py |
diffstat | 2 files changed, 8 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/__init__.py Wed Jun 03 11:45:17 2009 -0700 +++ b/__init__.py Wed Jun 03 13:29:28 2009 -0700 @@ -35,28 +35,11 @@ hg_repo_path += '-hg' dest_repo = hg.repository(ui, hg_repo_path, create=True) - print dest_repo - # fetch the initial git data git = GitHandler(dest_repo, ui) git.remote_add('origin', git_url) - import cProfile, pstats - import lsprofcalltree - prof = cProfile.Profile() - prof = prof.runctx("git.fetch('origin')", globals(), locals()) - stats = pstats.Stats(prof) - k = lsprofcalltree.KCacheGrind(prof) - data = open('/tmp/prof.kgrind', 'w+') - k.output(data) - data.close() - stats.sort_stats("cumulative") # Or cumulative - stats.print_stats(80) # 80 = how many to print - # The rest is optional. - #stats.print_callees() - #stats.print_callers() - - #git.fetch('origin') + git.fetch('origin') # checkout the tip node = git.remote_head('origin')
--- a/dulwich/repo.py Wed Jun 03 11:45:17 2009 -0700 +++ b/dulwich/repo.py Wed Jun 03 13:29:28 2009 -0700 @@ -108,6 +108,7 @@ self.path = root self.tags = Tags(self.tagdir(), self.get_tags()) self._object_store = None + self.tree_cache = {} def controldir(self): """Return the path of the control directory.""" @@ -315,7 +316,12 @@ return ret def get_object(self, sha): - return self.object_store[sha] + if sha in self.tree_cache: + return self.tree_cache[sha] + obj = self.object_store[sha] + if obj._type == 'tree': + self.tree_cache[sha] = obj + return obj def get_parents(self, sha): return self.commit(sha).parents