Commits

Michał Górny committed 2310403

Add a --remote-only option.

Comments (0)

Files changed (4)

smartliverebuild/cli.py

 		help='Configuration profile (config file section) to use (default: smart-live-rebuild)')
 	opt.add_option('-Q', '--quickpkg', action='store_true', dest='quickpkg',
 		help='Call quickpkg to create binary backups of packages which are going to be updated.')
+	opt.add_option('-r', '--remote-only', action='store_true', dest='remote_only',
+		help='Update remote-capable VCSes only (useful with --unprivileged-user).')
 	opt.add_option('-S', '--no-setuid', action='store_false', dest='setuid',
 		help='Do not switch UID to portage when FEATURES=userpriv is set.')
 	opt.add_option('-t', '--type', action='append', type='vcslist', dest='type',

smartliverebuild/config.py

 			'pretend': 'False',
 			'profile': 'smart-live-rebuild',
 			'quickpkg': 'False',
+			'remote_only': 'False',
 			'setuid': str('userpriv' in settings.features),
 			'type': '',
 			'unprivileged_user': 'False'

smartliverebuild/core.py

 								slottedcpv = cpv
 
 							for vcs in inherits:
-								vcscl = GetVCS(vcs, allowed)
+								vcscl = GetVCS(vcs, allowed, remote_only = opts.remote_only)
 								if vcscl is not None:
 									env = bz2.BZ2File('%s/environment.bz2' % db.getpath(cpv), 'r')
 									bash.grabenv(env)

smartliverebuild/vcsload.py

 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
+from smartliverebuild.vcs import RemoteVCSSupport
+
 class VCSLoader(object):
 	vcs_cache = {}
 
-	def __call__(self, eclassname, allowed = []):
+	def __call__(self, eclassname, allowed = [], remote_only = False):
 		if eclassname not in self.vcs_cache:
-			if allowed and eclassname not in allowed:
-				self.vcs_cache[eclassname] = None
-			else:
+			self.vcs_cache[eclassname] = None
+			if not allowed or eclassname in allowed:
 				modname = 'smartliverebuild.vcs.%s' % eclassname.replace('-', '_')
 				try:
 					mod = __import__(modname, {}, {}, ['.'], 0)
 				except ImportError:
-					self.vcs_cache[eclassname] = None
+					pass
 				else:
 					for k in dir(mod):
 						if k.endswith('Support') and \
 								k[:-7].lower() == eclassname.replace('-', ''):
-							self.vcs_cache[eclassname] = getattr(mod, k)
+							vcscl = getattr(mod, k)
+							if remote_only and not issubclass(vcscl, RemoteVCSSupport):
+								break
+							self.vcs_cache[eclassname] = vcscl
 							break
 					else:
 						raise ImportError('Unable to find a matching class in %s' % modname)
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.