def status(self, **kwargs): svn_status = super(GitSVNWorkingCopy, self).status(**kwargs) if svn_status == 'clean': return common.get_workingcopytypes()['git']( self.source).status(**kwargs) else: if kwargs.get('verbose', False): return svn_status, '' return svn_status
def get_sources(self): sources_dir = self.get_sources_dir() sources = {} sources_section = self.buildout['buildout'].get('sources', 'sources') section = self.buildout.get(sources_section, {}) workingcopytypes = get_workingcopytypes() for name in section: info = section[name].split() options = [] option_matcher = re.compile(r'[a-zA-Z0-9-]+=.*') for index, item in reversed(list(enumerate(info))): if option_matcher.match(item): del info[index] options.append(item) options.reverse() if len(info) < 2: logger.error("The source definition of '%s' needs at least the repository kind and URL." % name) sys.exit(1) kind = info[0] if kind not in workingcopytypes: logger.error("Unknown repository type '%s' for source '%s'." % (kind, name)) sys.exit(1) url = info[1] path = None if len(info) > 2: if '=' not in info[2]: logger.warn("You should use 'path=%s' to set the path." % info[2]) path = os.path.join(info[2], name) if not os.path.isabs(path): path = os.path.join(self.buildout_dir, path) options[:0] = info[3:] else: options[:0] = info[2:] if path is None: source = Source(kind=kind, name=name, url=url) else: source = Source(kind=kind, name=name, url=url, path=path) for option in options: key, value = option.split('=', 1) if not key: raise ValueError("Option with no name '%s'." % option) if key in source: raise ValueError("Key '%s' already in source info." % key) if key == 'path': value = os.path.join(value, name) if not os.path.isabs(value): value = os.path.join(self.buildout_dir, value) if key == 'full-path': if not os.path.isabs(value): value = os.path.join(self.buildout_dir, value) if key == 'egg': if value.lower() in ('true', 'yes', 'on'): value = True elif value.lower() in ('false', 'no', 'off'): value = False source[key] = value if 'path' not in source: if 'full-path' in source: source['path'] = source['full-path'] else: source['path'] = os.path.join(sources_dir, name) for rewrite in self.get_config().rewrites: rewrite(source) sources[name] = source return sources
def get_sources(self): from zc.buildout.buildout import MissingSection sources_dir = self.get_sources_dir() sources = {} sources_section = self.buildout['buildout'].get('sources', 'sources') try: section = self.buildout[sources_section] except MissingSection: if sys.exc_info()[1].args[0] == sources_section: section = {} else: raise workingcopytypes = get_workingcopytypes() for name in section: info = section[name].split() options = [] option_matcher = re.compile(r'[a-zA-Z0-9-]+=.*') for index, item in reversed(list(enumerate(info))): if option_matcher.match(item): del info[index] options.append(item) options.reverse() if len(info) < 2: logger.error( "The source definition of '%s' needs at least the repository kind and URL." % name) sys.exit(1) kind = info[0] if kind not in workingcopytypes: logger.error("Unknown repository type '%s' for source '%s'." % (kind, name)) sys.exit(1) url = info[1] path = None if len(info) > 2: if '=' not in info[2]: logger.warning( "You should use 'path=%s' to set the path." % info[2]) path = os.path.join(info[2], name) if not os.path.isabs(path): path = os.path.join(self.buildout_dir, path) options[:0] = info[3:] else: options[:0] = info[2:] if path is None: source = Source(kind=kind, name=name, url=url) else: source = Source(kind=kind, name=name, url=url, path=path) for option in options: key, value = option.split('=', 1) if not key: raise ValueError("Option with no name '%s'." % option) if key in source: raise ValueError("Key '%s' already in source info." % key) if key == 'path': value = os.path.join(value, name) if not os.path.isabs(value): value = os.path.join(self.buildout_dir, value) if key == 'full-path': if not os.path.isabs(value): value = os.path.join(self.buildout_dir, value) if key == 'egg': if value.lower() in ('true', 'yes', 'on'): value = True elif value.lower() in ('false', 'no', 'off'): value = False if key == 'depth': try: not_used = int(value) # noqa except ValueError: raise ValueError('depth value needs to be a number.') source[key] = value if 'path' not in source: if 'full-path' in source: source['path'] = source['full-path'] else: source['path'] = os.path.join(sources_dir, name) if 'depth' not in source and \ self.get_git_clone_depth(): source['depth'] = self.get_git_clone_depth() for rewrite in self.get_config().rewrites: rewrite(source) sources[name] = source return sources
def get_sources(self): sources_dir = self.get_sources_dir() sources = {} sources_section = self.buildout["buildout"].get("sources", "sources") section = self.buildout.get(sources_section, {}) workingcopytypes = get_workingcopytypes() for name in section: info = section[name].split() options = [] option_matcher = re.compile(r"[a-zA-Z0-9-]+=.*") for index, item in reversed(list(enumerate(info))): if option_matcher.match(item): del info[index] options.append(item) options.reverse() if len(info) < 2: logger.error("The source definition of '%s' needs at least the repository kind and URL." % name) sys.exit(1) kind = info[0] if kind not in workingcopytypes: logger.error("Unknown repository type '%s' for source '%s'." % (kind, name)) sys.exit(1) url = info[1] for rewrite in self.get_config().rewrites: if len(rewrite) == 2 and url.startswith(rewrite[0]): url = "%s%s" % (rewrite[1], url[len(rewrite[0]) :]) path = None if len(info) > 2: if "=" not in info[2]: logger.warn("You should use 'path=%s' to set the path." % info[2]) path = os.path.join(info[2], name) if not os.path.isabs(path): path = os.path.join(self.buildout_dir, path) options[:0] = info[3:] else: options[:0] = info[2:] if path is None: source = Source(kind=kind, name=name, url=url) else: source = Source(kind=kind, name=name, url=url, path=path) for option in options: key, value = option.split("=", 1) if not key: raise ValueError("Option with no name '%s'." % option) if key in source: raise ValueError("Key '%s' already in source info." % key) if key == "path": value = os.path.join(value, name) if not os.path.isabs(value): value = os.path.join(self.buildout_dir, value) if key == "full-path": if not os.path.isabs(value): value = os.path.join(self.buildout_dir, value) if key == "egg": if value.lower() in ("true", "yes", "on"): value = True elif value.lower() in ("false", "no", "off"): value = False source[key] = value if "path" not in source: if "full-path" in source: source["path"] = source["full-path"] else: source["path"] = os.path.join(sources_dir, name) sources[name] = source return sources