def __call__(self): output.warning('GIT repositories are not supported yet ' +\ '(only svn or gitsvn)') if len(self.args) == 0: output.error('package_name is required', exit=1) package_name = self.args[0] git.setup_gitsvn_cache() default_vcs = config.Configuration().default_vcs if default_vcs == 'git': # already checked out once? cache_path = os.path.join(git.get_gitsvn_cache_path(), package_name) if not os.path.isdir(cache_path): svn_url = self.get_svn_url(package_name) git.checkout_gitsvn(svn_url) else: # cache_path existing ; just update and clone runcmd('cd %s; git reset --hard' % cache_path) runcmd('cd %s; git svn fetch' % cache_path) runcmd('cd %s; git svn rebase' % cache_path) runcmd('cp -r %s .' % cache_path) runcmd('cd %s ; git checkout %s' % ( package_name, 'master', )) git.apply_svn_ignores(package_name) elif default_vcs == 'svn': svn_url = self.get_svn_url(package_name) runcmd('svn co %s %s' % ( svn_url, package_name))
def check_versions(self): output.part_title('Checking package versions') version_file = os.path.join(scm.get_package_name('.').replace('.', '/'), 'version.txt') trunk_version = open(version_file).read().strip() print ' * Current version of trunk: %s' %\ output.colorize(trunk_version, output.WARNING) next_version = trunk_version.split('-')[0] existing_tags = scm.get_existing_tags('.') if next_version in existing_tags.keys(): output.warning('Tag %s already existing' % next_version) # ask for next tag version prompt_msg = 'Which version do you want to release now? [%s]' % \ output.colorize(next_version, output.BOLD_WARNING) next_version_input = input.prompt(prompt_msg, lambda v:v in existing_tags.keys() and 'Tag already existing' or True) if next_version_input: next_version = next_version_input # ask for next trunk version next_trunk_version = next_version + '-dev' next_trunk_version = self.bump_version_proposal(next_trunk_version) prompt_msg = 'Which version should trunk have afterwards? [%s]' % \ output.colorize(next_trunk_version, output.BOLD_WARNING) next_trunk_version_input = input.prompt(prompt_msg) if next_trunk_version_input: next_trunk_version = next_trunk_version_input print ' * The version of the tag will be: %s' %\ output.colorize(next_version, output.WARNING) print ' * New version of the trunk will be: %s' %\ output.colorize(next_trunk_version, output.WARNING) self.new_tag_version = next_version self.new_trunk_version = next_trunk_version
def __call__(self): if len(self.args)<2: output.error('At least 2 arguments are required', exit=1) if len(self.args)>3: output.error('At most 3 arguments are required', exit=1) # extract and check arguments if len(self.args)==2: self.fromnr, self.action = self.args self.tonr = self.fromnr elif len(self.args)==3: self.fromnr, self.tonr, self.action = self.args self.fromnr = int(self.unalias(self.fromnr)) self.tonr = int(self.unalias(self.tonr)) if self.tonr < self.fromnr: output.error('FROM (%s) must be lower than TO (%s)' % ( str(self.fromnr), str(self.tonr), )) # find instances instance_names = ['instance' + str(self.alias(x)) for x in range(self.fromnr, self.tonr+1)] instance_paths = [] for name in instance_names: path = os.path.join(self.find_buildout_directory(), 'bin', name) if os.path.exists(path): instance_paths.append(path) print ' * found %s' % path else: output.warning('%s not found: skipping' % path) # call instances for i, path in enumerate(instance_paths): if i!=0 and self.options.delay: print ' * waiting for %s second' % str(self.options.delay) time.sleep(self.options.delay) runcmd('%s %s' % (path, self.action))
def tested_for_scms(scms=("svn"), dir="."): """Marks a command as tested for one or more of ('git', 'gitsvn', 'svn'). Calling this function checks if the repository-type in `dir` is one of `scms`. """ if not is_scm(dir): raise NotAScm elif "svn" in scms and is_subversion(dir): # svn check always before git checks! return True elif "gitsvn" in scms and is_git_svn(dir): return True elif "git" in scms and is_git(dir): return True else: # ask if the user wants to continue output.warning( "This command is not tested for your source control system " + "(for %s) " % dir + "Tested systems are: %s" % str(scms) ) if input.prompt_bool("Do you really want to continue? It may make damage!", default=False): if input.prompt_bool("REALLY SURE???", default=False): return False sys.exit(0)
def checkout_gitsvn(svn_url, location='.'): svn_url = svn_url[-1]=='/' and svn_url[:-1] or svn_url root_url = svn.get_package_root_url(svn_url) if not svn.isdir(svn_url): raise svn.InvalidSubversionURL expected_dirs = ('trunk', 'tags', 'branches') got_dirs = expected_dirs try: svn.check_project_layout(svn_url) except svn.InvalidProjectLayout: # check the directories and print a warning dircontent = runcmd('svn ls %s' % svn_url, log=False, respond=True) dircontent = [x.strip()[:-1] for x in dircontent] got_dirs = [] missing_dirs = [] for dir in expected_dirs: if dir in dircontent: got_dirs.append(dir) else: missing_dirs.append(dir) output.warning('Directory %s missing!' % dir) package_name = svn.get_package_name(svn_url) cache_path = os.path.join(get_gitsvn_cache_path(), package_name) if os.path.exists(package_name): raise Exception('%s already existing' % os.path.abspath(package_name)) gitbranch = svnurl_get_gitbranch(svn_url) # clone it if os.path.exists(cache_path): runcmd('cd %s; git reset --hard' % cache_path) runcmd('cd %s; git svn fetch' % cache_path) runcmd('cd %s; git svn rebase' % cache_path) else: if got_dirs==expected_dirs: # we have a standard layout cmd = 'cd %s; git svn clone --stdlayout %s' % ( get_gitsvn_cache_path(), root_url, ) else: # some dirs are missing args = ['--%s=%s' % (d,d) for d in got_dirs] cmd = 'cd %s; git svn clone %s %s' % ( get_gitsvn_cache_path(), ' '.join(args), root_url, ) runcmd(cmd) runcmd('cp -r %s %s' % (cache_path, location)) co_path = os.path.join(location, package_name) runcmd('cd %s ; git checkout %s' % ( co_path, gitbranch, )) runcmd('cd %s ; git reset --hard' % co_path) runcmd('cd %s ; git svn rebase' % co_path)
def __call__(self): if not self.options.quiet: output.warning('Git repositories are not supported yet!') try: if self.options.verbose: from ftw.manager import utils utils.FORCE_LOG = True if self.options.history: self.print_history() else: self.print_table() finally: self.delete_downloaded_files()
def __call__(self): # warning output.warning('It\'s no longer recommended to use a installation ' +\ 'in site-packages, since we have a implicit ' +\ 'dependency to zope.') output.warning('Use the buildout instead: ' +\ 'https://svn.4teamwork.ch/repos/buildout/ftw.manager/') output.error('Quitting. See help for enforcing update...') if not self.options.ignore_warning: return # / warning from pkg_resources import load_entry_point easy_install = load_entry_point('setuptools==0.6c9', 'console_scripts', 'easy_install') easy_install(['-U', '-f', self.options.findLinks, 'ftw.manager'])
def check_manifest(self): """ Checks the MANIFEST.in file and gives advices. It returns if the release action can be continued """ if self.options.release_egg_only: return True namespace = scm.get_package_name('.').split('.')[0] required_lines = ( 'recursive-include %s *' % namespace, 'recursive-include docs *', 'include *.txt', 'global-exclude *.pyc', 'global-exclude ._*', ) unused_lines = ( 'include setup.py', 'include README.txt', 'include CONTRIBUTORS.txt', 'global-exclude *pyc', 'global-exclude *mo', 'global-exclude *.mo', ) created = False modified = False commit_message = '' if not os.path.isfile('MANIFEST.in'): output.warning('Could not find the file ./MANIFEST.in, creating one') f = open('MANIFEST.in', 'w') f.write('\n'.join(required_lines)) f.close() print 'created MANIFEST.in with following content:' print output.colorize(open('MANIFEST.in').read(), output.INFO) print '' commit_message = 'added MANIFEST.in for %s' % scm.get_package_name('.') created = True else: # check the existing file current_lines = [x.strip() for x in open('MANIFEST.in').readlines()] missing_lines = [x for x in required_lines if x.strip() not in current_lines] files_to_remove = [x for x in unused_lines if x.strip() in current_lines] if len(missing_lines) > 0 or len(files_to_remove) > 0: new_lines = current_lines if len(missing_lines) > 0: output.warning('./MANIFEST.in: added some required lines:') print output.colorize('\n'.join(missing_lines), output.INFO) print '' new_lines += missing_lines if len(files_to_remove) > 0: output.warning('./MANIFEST.in: removed some unused lines:') print output.colorize('\n'.join(files_to_remove), output.ERROR) print '' new_lines = filter(lambda x:x.strip() not in files_to_remove, new_lines) f = open('MANIFEST.in', 'w') f.write('\n'.join(new_lines)) f.close() commit_message = 'updated MANIFEST.in for %s' % scm.get_package_name('.') modified = True if created or modified: # commit it ? if input.prompt_bool('Would you like to commit the MANIFEST.in?'): if created: scm.add_and_commit_files(commit_message, 'MANIFEST.in') return True elif modified: scm.commit_files(commit_message, 'MANIFEST.in') return True return False else: return True