Michał Górny avatar Michał Górny committed 2b1763f

Move VCS class grabbing to SmartLiveRebuild.vcs.

Comments (0)

Files changed (2)


 	from ConfigParser import ConfigParser, NoOptionError
 from SmartLiveRebuild.output import out
-from SmartLiveRebuild.vcs import NonLiveEbuild
+from SmartLiveRebuild.vcs import NonLiveEbuild, GetVCS
 class Config(ConfigParser):
 	def __init__(self, settings = None):
 						del processes[i]
 				return needsleep
-			vcses = {}
 			bash = BashParser()
 							inherits = db.aux_get(cpv, ['INHERITED'])[0].split()
 							for vcs in inherits:
-								if vcs not in vcses:
-									if allowed and vcs not in allowed:
-										vcses[vcs] = None
-									else:
-										try:
-											modname = 'SmartLiveRebuild.vcs.%s' % vcs.replace('-', '_')
-											vcses[vcs] = __import__(modname, globals(), locals(), ['myvcs']).myvcs
-										except ImportError:
-											vcses[vcs] = None
-								if vcses[vcs] is not None:
+								vcscl = GetVCS(vcs, allowed)
+								if vcscl is not None:
 									env = bz2.BZ2File('%s/environment.bz2' % db.getpath(cpv), 'r')
-									vcs = vcses[vcs](cpv, bash, opts, settings)
+									vcs = vcscl(cpv, bash, opts, settings)
 									if opts.network or vcs.getsavedrev():
 										dir = vcs.getpath()


 	def __str__(self):
 		return ', '.join(self.cpv)
+vcs_cache = {}
+def GetVCS(eclassname, allowed = []):
+	if eclassname not in vcs_cache:
+		if allowed and eclassname not in allowed:
+			vcs_cache[eclassname] = None
+		else:
+			try:
+				modname = 'SmartLiveRebuild.vcs.%s' % eclassname.replace('-', '_')
+				vcs_cache[eclassname] = __import__(modname, globals(), locals(), ['myvcs']).myvcs
+			except ImportError:
+				vcs_cache[eclassname] = None
+	return vcs_cache[eclassname]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.