Cache (non-cloned) repository URLs to reduce lookups
authorKalle Vahlman <kalle.vahlman@movial.com>
Thu, 14 May 2009 07:28:53 +0000 (10:28 +0300)
committerKalle Vahlman <kalle.vahlman@movial.com>
Thu, 14 May 2009 07:28:53 +0000 (10:28 +0300)
matrix/repositories.py

index f437141..a3a2ec3 100644 (file)
@@ -117,7 +117,21 @@ class Repository(object):
                if config.debug:
                        print 'Fetching hash', self
 
-               url, branch = self.__get_url_branch()
+               # Cache the url where we found the repo to reduce lookups
+               if not os.path.exists(self.path + "/.matrix_repo_url_branch"):
+                       url, branch = self.__get_url_branch()
+                       file = open(self.path + "/.matrix_repo_url_branch", 'w')
+                       try:
+                               print >>file, url + "==" + branch
+                       finally:
+                               file.close()
+               else:
+                       file = open(self.path + "/.matrix_repo_url_branch", 'r')
+                       try:
+                               url, branch = file.readline().split('==')
+                       finally:
+                               file.close()
+
 
                if not self.__hash:
                        if not os.path.exists(self.path + "/.matrix_repo_hash") or update: