Mercurial > hg > hg-git
diff hggit/git_handler.py @ 552:bff92a208c3f
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.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Wed, 17 Oct 2012 10:50:55 -0500 |
parents | ccd521a1f585 |
children | f3f344aac42b 1ab57b19cb3a |
line wrap: on
line diff
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -86,8 +86,21 @@ 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() - 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,13 +136,11 @@ 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) - 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)