Mercurial > hg > hg-git
changeset 692:6ab17ae0c834
git_handler: make self.git a lazily evaluated property
This allows other functions to be able to use the `git` property without
needing to care about initializing it.
An upcoming patch will remove the `init_if_missing` function.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Tue, 25 Feb 2014 19:51:02 -0800 (2014-02-26) |
parents | c99941ff2d28 |
children | cf3bb80a666e |
files | hggit/git_handler.py |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -123,13 +123,17 @@ self.load_map() return self._map_hg_real - # make the git data directory - def init_if_missing(self): + @hgutil.propertycache + def git(self): + # make the git data directory if os.path.exists(self.gitdir): - self.git = Repo(self.gitdir) + return Repo(self.gitdir) else: os.mkdir(self.gitdir) - self.git = Repo.init_bare(self.gitdir) + return Repo.init_bare(self.gitdir) + + def init_if_missing(self): + pass def init_author_file(self): self.author_map = {}