changeset 106:3aa2f6caed16

make the gitdir a constant
author Sverre Rabbelier <sverre@rabbelier.nl>
date Sun, 10 May 2009 10:42:44 -0700
parents 41e76444105c
children 8c83d2021b03
files git_handler.py
diffstat 1 files changed, 8 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/git_handler.py	Sun May 10 10:37:23 2009 -0700
+++ b/git_handler.py	Sun May 10 10:42:44 2009 -0700
@@ -50,6 +50,7 @@
         self.ui = ui
         self.mapfile = 'git-mapfile'
         self.configfile = 'git-config'
+        self.gitdir = self.repo.join('git')
         self.init_if_missing()
         self.load_git()
         self.load_map()
@@ -57,14 +58,12 @@
 
     # make the git data directory
     def init_if_missing(self):
-        git_hg_path = os.path.join(self.repo.path, 'git')
-        if not os.path.exists(git_hg_path):
-            os.mkdir(git_hg_path)
-            Repo.init_bare(git_hg_path)
+        if not os.path.exists(self.gitdir):
+            os.mkdir(self.gitdir)
+            Repo.init_bare(self.gitdir)
 
     def load_git(self):
-        git_dir = os.path.join(self.repo.path, 'git')
-        self.git = Repo(git_dir)
+        self.git = Repo(self.gitdir)
 
     ## FILE LOAD AND SAVE METHODS
 
@@ -597,14 +596,13 @@
         return SubprocessGitClient(), uri
 
     def clear(self):
-        git_dir = self.repo.join('git')
         mapfile = self.repo.join(self.mapfile)
-        if os.path.exists(git_dir):
-            for root, dirs, files in os.walk(git_dir, topdown=False):
+        if os.path.exists(self.gitdir):
+            for root, dirs, files in os.walk(self.gitdir, topdown=False):
                 for name in files:
                     os.remove(os.path.join(root, name))
                 for name in dirs:
                     os.rmdir(os.path.join(root, name))
-            os.rmdir(git_dir)
+            os.rmdir(self.gitdir)
         if os.path.exists(mapfile):
             os.remove(mapfile)