Просмотр исходного кода

Allow callers of GitConfig to specify the pickle file path

This way we can put it in another directory than the config file
itself, e.g. hide it inside ".git" when parsing a ".gitmodules"
file from the working tree.

Signed-off-by: Shawn O. Pearce <sop@google.com>
Shawn O. Pearce 16 лет назад
Родитель
Сommit
1b34c9118e
1 измененных файлов с 8 добавлено и 4 удалено
  1. 8 4
      git_config.py

+ 8 - 4
git_config.py

@@ -56,16 +56,20 @@ class GitConfig(object):
     return cls(file = os.path.join(gitdir, 'config'),
     return cls(file = os.path.join(gitdir, 'config'),
                defaults = defaults)
                defaults = defaults)
 
 
-  def __init__(self, file, defaults=None):
+  def __init__(self, file, defaults=None, pickleFile=None):
     self.file = file
     self.file = file
     self.defaults = defaults
     self.defaults = defaults
     self._cache_dict = None
     self._cache_dict = None
     self._section_dict = None
     self._section_dict = None
     self._remotes = {}
     self._remotes = {}
     self._branches = {}
     self._branches = {}
-    self._pickle = os.path.join(
-      os.path.dirname(self.file),
-      '.repopickle_' + os.path.basename(self.file))
+
+    if pickleFile is None:
+      self._pickle = os.path.join(
+        os.path.dirname(self.file),
+        '.repopickle_' + os.path.basename(self.file))
+    else:
+      self._pickle = pickleFile
 
 
   def Has(self, name, include_defaults = True):
   def Has(self, name, include_defaults = True):
     """Return true if this configuration file has the key.
     """Return true if this configuration file has the key.