diff git_handler.py @ 258:1590c97d7af0

do not init the cache git repo unless needed (fixes issue 16 bb)
author Abderrahim Kitouni <a.kitouni@gmail.com>
date Thu, 15 Oct 2009 21:45:15 +0100
parents bfe6fd2fdb9b
children
line wrap: on
line diff
--- a/git_handler.py	Thu Oct 08 19:50:09 2009 +0100
+++ b/git_handler.py	Thu Oct 15 21:45:15 2009 +0100
@@ -33,19 +33,16 @@
 
         self.paths = ui.configitems('paths')
 
-        self.init_if_missing()
-        self.load_git()
         self.load_map()
         self.load_tags()
 
     # make the git data directory
     def init_if_missing(self):
-        if not os.path.exists(self.gitdir):
+        if os.path.exists(self.gitdir):
+            self.git = Repo(self.gitdir)
+        else:
             os.mkdir(self.gitdir)
-            Repo.init_bare(self.gitdir)
-
-    def load_git(self):
-        self.git = Repo(self.gitdir)
+            self.git = Repo.init_bare(self.gitdir)
 
     ## FILE LOAD AND SAVE METHODS
 
@@ -176,6 +173,8 @@
 
     def export_git_objects(self):
         self.ui.status(_("importing Hg objects into Git\n"))
+        self.init_if_missing()
+
         nodes = [self.repo.lookup(n) for n in self.repo]
         export = [node for node in nodes if not hex(node) in self._map_hg]
         total = len(export)
@@ -352,6 +351,8 @@
 
     def import_git_objects(self, remote_name=None, refs=None):
         self.ui.status(_("importing Git objects into Hg\n"))
+        self.init_if_missing()
+
         # import heads and fetched tags as remote references
         todo = []
         done = set()