# HG changeset patch # User Siddharth Agarwal # Date 1393386662 28800 # Node ID 6ab17ae0c8344fcb96c7474cea900c8a39000798 # Parent c99941ff2d287d2b1d76ceab4b3881974ede5f7c 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. diff --git a/hggit/git_handler.py b/hggit/git_handler.py --- 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 = {}