Skip to content
Snippets Groups Projects
Commit bff92a20 authored by durin42's avatar durin42
Browse files

git_handler: lazy-load mapping

Loading the mapping was costing about half a second for a user on IRC
on the pidgin repo. There's no reason to load this data aggressively.
parent ccd521a1
No related branches found
No related tags found
No related merge requests found
......@@ -86,4 +86,11 @@
self.branch_bookmark_suffix = ui.config('git', 'branch_bookmark_suffix')
self._map_git_real = {}
self._map_hg_real = {}
self.load_tags()
@property
def _map_git(self):
if not self._map_git_real:
self.load_map()
......@@ -89,5 +96,11 @@
self.load_map()
self.load_tags()
return self._map_git_real
@property
def _map_hg(self):
if not self._map_hg_real:
self.load_map()
return self._map_hg_real
# make the git data directory
def init_if_missing(self):
......@@ -123,8 +136,6 @@
return self._map_hg.get(hgsha)
def load_map(self):
self._map_git = {}
self._map_hg = {}
if os.path.exists(self.repo.join(self.mapfile)):
for line in self.repo.opener(self.mapfile):
gitsha, hgsha = line.strip().split(' ', 1)
......@@ -128,8 +139,8 @@
if os.path.exists(self.repo.join(self.mapfile)):
for line in self.repo.opener(self.mapfile):
gitsha, hgsha = line.strip().split(' ', 1)
self._map_git[gitsha] = hgsha
self._map_hg[hgsha] = gitsha
self._map_git_real[gitsha] = hgsha
self._map_hg_real[hgsha] = gitsha
def save_map(self):
file = self.repo.opener(self.mapfile, 'w+', atomictemp=True)
......
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