class VersionningComponent(Component): API_VERSION = 1 NAME = 'versionning' VERSION = '1.0' REQUIRES = () def __init__(self): Component.__init__(self) self.repositories = {} self.client = Client() def init(self, core): vardir = core.config.get('CORE', 'vardir') self.repositories_base = join(vardir, "repositories") self.checkout_base = join(vardir, "versionned") for directory in (self.repositories_base, self.checkout_base): if not exists(directory): mkdir(directory) def getRepository(self, name): if name not in self.repositories: self.createOrLoadRepository(name) return self.repositories[name] def createOrLoadRepository(self, name): repository_directory = join(self.repositories_base, name) checkout_directory = join(self.checkout_base, name) must_create = not exists(repository_directory) assert must_create != exists(checkout_directory) if must_create: self.createRepository(repository_directory, checkout_directory) repository = Repository(self, checkout_directory, client=self.client) if must_create: repository.update() self.repositories[name] = repository def createRepository(self, repository_directory, checkout_directory): process = createProcess(self, ["svnadmin", "create", repository_directory]) result = waitProcess(self, process, 20) if result != 0: raise VersionningError("error creating repository %s" % repository_directory) self.client.checkout("file://%s" % repository_directory, checkout_directory) def service_listRepositories(self, context): for key, value in self.repositories.iteritems(): yield key, value.checkout_directory def service_commit_all(self, context, message): for repository in self.repositories.values(): repository.commit(message, delete_missing=True)
def checkout_v8(): if svn_name: print("INFO: we will try to update v8 to %s at <%s>" % (svn_name, V8_SVN_URL)) else: print("INFO: we will try to checkout and build a private v8 build from <%s>." % V8_SVN_URL) print("=" * 20) print("INFO: Checking out or Updating Google V8 code from SVN...\n") update_code = os.path.isdir(V8_HOME) and os.path.exists(os.path.join(V8_HOME, 'include', 'v8.h')) try: from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision(opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: print("%s Google V8 code (r%d) from SVN to %s" % ("Update" if update_code else "Checkout", r[-1].number, V8_HOME)) with open(v8_svn_rev_file, 'w') as f: f.write(str(r[-1].number)) return print("ERROR: Failed to export from V8 svn repository") except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print("INFO: we will try to use the system 'svn' command to checkout/update V8 code") if update_code: args = ["svn", "up", V8_HOME] else: os.makedirs(V8_HOME) args = ["svn", "co", V8_SVN_URL, V8_HOME] if V8_SVN_REVISION: args += ['-r', str(V8_SVN_REVISION)] if exec_cmd(' '.join(args), "checkout or update Google V8 code from SVN"): if not V8_SVN_REVISION: ok, out, err = exec_cmd(' '.join(["svn", "info", V8_HOME]), "save the current V8 SVN revision to REVISION file", output=True) if ok: with open(v8_svn_rev_file, 'w') as f: f.write(re.search(r'Revision:\s(?P<rev>\d+)', out, re.MULTILINE).groupdict()['rev']) else: print("ERROR: fail to fetch SVN info, %s", err)
def checkout_v8(): if svn_name: print("INFO: we will try to update v8 to %s at <%s>" % (svn_name, V8_SVN_URL)) else: print( "INFO: we will try to checkout and build a private v8 build from <%s>." % V8_SVN_URL) print("=" * 20) print("INFO: Checking out or Updating Google V8 code from SVN...\n") update_code = os.path.isdir(V8_HOME) and os.path.exists( os.path.join(V8_HOME, 'include', 'v8.h')) try: from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision( opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: return print("ERROR: Failed to export from V8 svn repository") except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print( "INFO: we will try to use the system 'svn' command to checkout/update V8 code" ) if update_code: args = ["svn", "up", V8_HOME] else: os.makedirs(V8_HOME) args = ["svn", "co", V8_SVN_URL, V8_HOME] if V8_SVN_REVISION: args += ['-r', str(V8_SVN_REVISION)] cmdline = ' '.join(args) exec_cmd(cmdline, "checkout or update Google V8 code from SVN")
def checkout_v8(self): update_code = os.path.isdir(V8_HOME) and os.path.exists( os.path.join(V8_HOME, 'include', 'v8.h')) try: from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision( opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: return print "ERROR: Failed to export from V8 svn repository" except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print "INFO: we will try to use the system 'svn' command to checkout/update V8 code" if update_code: args = ["svn", "up", V8_HOME] else: os.makedirs(V8_HOME) args = ["svn", "co", V8_SVN_URL, V8_HOME] if V8_SVN_REVISION: args += ['-r', str(V8_SVN_REVISION)] try: proc = subprocess.Popen(args, stdout=sys.stdout, stderr=sys.stderr) proc.communicate() if proc.returncode != 0: print "WARN: fail to checkout or update Google v8 code from SVN, error code: ", proc.returncode except Exception, e: print "ERROR: fail to invoke 'svn' command, please install it first: %s" % e sys.exit(-1)
def checkout_v8(): if svn_name: print("INFO: we will try to update v8 to %s at <%s>" % (svn_name, V8_SVN_URL)) else: print("INFO: we will try to checkout and build a private v8 build from <%s>." % V8_SVN_URL) print("=" * 20) print("INFO: Checking out or Updating Google V8 code from SVN...\n") update_code = os.path.isdir(V8_HOME) and os.path.exists(os.path.join(V8_HOME, 'include', 'v8.h')) try: from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision(opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: print("%s Google V8 code (r%d) from SVN to %s" % ("Update" if update_code else "Checkout", r[-1].number, V8_HOME)) return print("ERROR: Failed to export from V8 svn repository") except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print("INFO: we will try to use the system 'svn' command to checkout/update V8 code") if update_code: args = ["svn", "up", V8_HOME] else: os.makedirs(V8_HOME) args = ["svn", "co", V8_SVN_URL, V8_HOME] if V8_SVN_REVISION: args += ['-r', str(V8_SVN_REVISION)] cmdline = ' '.join(args) exec_cmd(cmdline, "checkout or update Google V8 code from SVN")
def checkout_v8(self): update_code = os.path.isdir(V8_HOME) and os.path.exists(os.path.join(V8_HOME, 'include', 'v8.h')) try: from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision(opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: return print "ERROR: Failed to export from V8 svn repository" except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print "INFO: we will try to use the system 'svn' command to checkout/update V8 code" if update_code: args = ["svn", "up", V8_HOME] else: os.makedirs(V8_HOME) args = ["svn", "co", V8_SVN_URL, V8_HOME] if V8_SVN_REVISION: args += ['-r', str(V8_SVN_REVISION)] try: proc = subprocess.Popen(args, stdout=sys.stdout, stderr=sys.stderr) proc.communicate() if proc.returncode != 0: print "WARN: fail to checkout or update Google v8 code from SVN, error code: ", proc.returncode except Exception, e: print "ERROR: fail to invoke 'svn' command, please install it first: %s" % e sys.exit(-1)
def checkout_v8(): if svn_name: print("INFO: we will try to update v8 to %s at <%s>" % (svn_name, V8_SVN_URL)) else: print("INFO: we will try to checkout and build a private v8 build from <%s>." % V8_SVN_URL) print("=" * 20) print("INFO: Checking out or Updating Google V8 code from SVN...\n") update_code = os.path.isdir(V8_HOME) and os.path.exists(os.path.join(V8_HOME, 'include', 'v8.h')) try: print('skipping pysvn install') raise ImportError('Skip attempt to use python-svn/pysvn') from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision(opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: print("%s Google V8 code (r%d) from SVN to %s" % ("Update" if update_code else "Checkout", r[-1].number, V8_HOME)) with open(v8_svn_rev_file, 'w') as f: f.write(str(r[-1].number)) return print("ERROR: Failed to export from V8 svn repository") except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print("INFO: we will try to use the system 'svn' command to checkout/update V8 code") # print('PYv8Home %s' % PYV8_HOME) # print('V8_HOME: exiting\n>%s<' % V8_HOME) # import sys # sys.exit(42) if update_code and False: args = ["svn", "up", V8_HOME] # svn: svn up(date) V8_HOME # git: git pull (repository path to update) git_args = ["git", "--work-tree="+V8_HOME,"--git-dir"+V8_HOME+"/.git","pull"] else: os.makedirs(V8_HOME) # make the folder args = ["svn", "co", V8_SVN_URL, V8_HOME] # svn: svn checkout (repo to clone) (location to put it) # git: git clone (repo to clone) (location to put it) git_args = ["git", "clone", V8_GIT_URL, V8_HOME] if V8_SVN_REVISION: # if there is a specific version to pull args += ['-r', str(V8_SVN_REVISION)] # svn: -r specifies the "commit"/branch id/tag whatever to use as version # git: can clone just a specific branch. I'd rather clone it all and checkout # a specific branch, then pull its changes just in case if exec_cmd(' '.join(git_args), "git clone a new repository for Google v8 code"): print('I think it cloned') '''
def checkout_v8(): if svn_name: print("INFO: we will try to update v8 to %s at <%s>" % (svn_name, V8_SVN_URL)) else: print( "INFO: we will try to checkout and build a private v8 build from <%s>." % V8_SVN_URL) print("=" * 20) print("INFO: Checking out or Updating Google V8 code from SVN...\n") update_code = os.path.isdir(V8_HOME) and os.path.exists( os.path.join(V8_HOME, 'include', 'v8.h')) try: from pysvn import Client, Revision, opt_revision_kind svnClient = Client() rev = Revision(opt_revision_kind.number, V8_SVN_REVISION) if V8_SVN_REVISION else Revision( opt_revision_kind.head) if update_code: r = svnClient.update(V8_HOME, revision=rev) else: r = svnClient.checkout(V8_SVN_URL, V8_HOME, revision=rev) if r: print("%s Google V8 code (r%d) from SVN to %s" % ("Update" if update_code else "Checkout", r[-1].number, V8_HOME)) with open(v8_svn_rev_file, 'w') as f: f.write(str(r[-1].number)) return print("ERROR: Failed to export from V8 svn repository") except ImportError: #print "WARN: could not import pysvn. Ensure you have the pysvn package installed." #print " on debian/ubuntu, this is called 'python-svn'; on Fedora/RHEL, this is called 'pysvn'." print( "INFO: we will try to use the system 'svn' command to checkout/update V8 code" ) if update_code: args = ["svn", "up", V8_HOME] else: os.makedirs(V8_HOME) args = ["svn", "co", V8_SVN_URL, V8_HOME] if V8_SVN_REVISION: args += ['-r', str(V8_SVN_REVISION)] if exec_cmd(' '.join(args), "checkout or update Google V8 code from SVN"): if not V8_SVN_REVISION: ok, out, err = exec_cmd( ' '.join(["svn", "info", V8_HOME]), "save the current V8 SVN revision to REVISION file", output=True) if ok: with open(v8_svn_rev_file, 'w') as f: f.write( re.search(r'Revision:\s(?P<rev>\d+)', out, re.MULTILINE).groupdict()['rev']) else: print("ERROR: fail to fetch SVN info, %s", err)