def getRepoPaths( self, path_section ): ctxAssert( path_section in ctx_repo.REPO_PATH_SECTIONS, "Unknown path section '%s'"%(path_section) ) paths = list() for repo in self.getRepositories(): paths.extend( repo.getFullPaths( path_section ) ) return paths
def update(self): ctxAssert( self.isLocal(), "This method should not be called without first checking for an existing working copy." ) infoMessage("Updating RSpec repository '%s' (%s)"%(self.getID(), self.getHref()), 1) self.client.updateWorkingCopy( self.getAbsLocalPath(), self.getRSpecRevision() )
def update(self): if not treesAreEqual( self.getAbsLocalPath(), self.getHref() ): print >>sys.stderr, '\n' infoMessage("Regular file repository '%s' is out of sync.\n'%s' and '%s' doesn't match. The system is unable to\nperform intelligent synchronization of non-revisioned repositories.\nDo you want to overwrite (delete and replace) the local copy '%s'\nwith the contents of the remote copy '%s'?"\ %(self.getID(), self.getAbsLocalPath(), self.getHref(), self.getAbsLocalPath(), self.getHref() ), 0) choice = raw_input( "> yes/no: " ).lower() while choice not in ['yes','no']: infoMessage("Invalid choice, try again.", 0) choice = raw_input( "> yes/no: " ).lower() if choice == 'yes': infoMessage("Updating (replacing) local copy '%s' with '%s'"\ %(self.getAbsLocalPath(), self.getHref()), 1) shutil.rmtree( self.getAbsLocalPath() ) shutil.copytree( self.getHref(), self.getAbsLocalPath() ) elif choice == 'no': infoMessage("Skipping update of repository '%s'"%self.getID(), 2) else: ctxAssert( False, "Unhandled choice" ) else: infoMessage("Repository '%s' (%s) is up to date"%(self.getID(), self.getHref()), 1)
def checkout(self): import shutil import ctx_view ctxAssert( self.isLocal() == False, "This method should not be called without first checking for an existing local copy." ) infoMessage("Checking out repository '%s' (%s) to '%s'" %(self.getID(), self.getHref(), self.getAbsLocalPath()), 1) shutil.copytree( self.getHref(), self.getAbsLocalPath() )
def checkout(self): ctxAssert( self.isLocal() == False, "This method should not be called without first checking for an existing working copy." ) infoMessage("Checking out RSpec repository '%s' (%s)"%(self.getID(), self.getHref()), 1) if not os.path.isdir(self.getAbsLocalPath()): os.makedirs( self.getAbsLocalPath() ) self.client.checkout( self.getHref(), self.getAbsLocalPath(), self.getRSpecRevision() )
def getRevisionFromWorkingCopy( self, lc_path ): if not os.path.exists(lc_path): userErrorExit("Given path to local copy '%s' is invalid"%(lc_path)) entry = self.client.info( lc_path ) if entry.revision.kind == pysvn.opt_revision_kind.head: return 'HEAD' elif entry.revision.kind == pysvn.opt_revision_kind.number: return entry.revision.number else: ctxAssert( False, "Unhandled pysvn revision kind" )
def isWorkingCopy( self, local_path ): try: entry = self.client.info( local_path ) except pysvn.ClientError, e: for message, code in e.args[1]: if code in [ERR_NOT_A_WORKING_COPY, ERR_INVALID_ARGUMENT]: return False elif code == ERR_UNSUPPORTED_WORKING_COPY_FORMAT: userErrorExit("Unsupported working copy format in '%s'\n \ Looks like the working copy was accessed using an incomptatible version of a svn client\n. \ PySvn currently uses svn version %s. "%(local_path, pysvn.svn_version) ) else: ctxAssert( False, "Unhandled pysvn exception: (%d) %s. This code need to be updated." )
def checkout(self): import shutil import ctx_view ctxAssert( self.isLocal() == False, "This method should not be called without first checking for an existing local copy." ) if self.getAccessPolicy() == ctx_view.AP_PREFER_REMOTE_ACCESS: infoMessage("Repository '%s' (%s) is accessible from its remote location, skipping checkout." %(self.getID(), self.getHref()), 1) elif self.getAccessPolicy() == ctx_view.AP_NO_REMOTE_ACCESS: infoMessage("Checking out repository '%s' (%s) to '%s'" %(self.getID(), self.getHref(), self.getAbsLocalPath()), 1) shutil.copytree( self.getHref(), self.getAbsLocalPath() ) else: ctxAssert( False, "Unhandled access policy '%d'"%self.getAccessPolicy() )
def genTreeChecksum( root_folder, md5_checksum ): ctxAssert( os.path.isdir(root_folder), "Existance of folder must be checked prior to this call" ) folder_items = os.listdir( root_folder ) for item_name in folder_items: md5_checksum.update( item_name ) item_path = os.path.join( root_folder, item_name ) if os.path.isdir( item_path ): genTreeChecksum( item_path, md5_checksum ) # POINT OF RECURSION else: ctxAssert( os.path.isfile(item_path), "Path concatenation probably went wrong here" ) f = open( item_path, 'rb' ) contents = f.read() f.close() md5_checksum.update( contents ) return md5_checksum
def update(self): import ctx_view ctxAssert( self.isLocal(), "This method should not be called without first checking for an existing local copy." ) ctxAssert( self.getAccessPolicy() != None, "No access policy has been set for repository '%s'"%(self.getID()) ) if self.getAccessPolicy() == ctx_view.AP_PREFER_REMOTE_ACCESS: infoMessage("Repository '%s' (%s) is accessed from its remote location, skipping update."%(self.getID(), self.getHref()), 1) elif self.getAccessPolicy() == ctx_view.AP_NO_REMOTE_ACCESS: if not treesAreEqual( self.getAbsLocalPath(), self.getHref() ): print '\n' infoMessage("Regular file repository '%s' is out of sync.\n'%s' and '%s' doesn't match. The system is unable to\nperform intelligent synchronization of non-revisioned repositories.\nDo you want to overwrite (delete and replace) the local copy '%s'\nwith the contents of the remote copy '%s'?"\ %(self.getID(), self.getAbsLocalPath(), self.getHref(), self.getAbsLocalPath(), self.getHref() ), 0) choice = raw_input( "> yes/no: " ).lower() while choice not in ['yes','no']: infoMessage("Invalid choice, try again.", 0) choice = raw_input( "> yes/no: " ).lower() if choice == 'yes': infoMessage("Updating (replacing) local copy '%s' with '%s'"\ %(self.getAbsLocalPath(), self.getHref()), 1) shutil.rmtree( self.getAbsLocalPath() ) shutil.copytree( self.getHref(), self.getAbsLocalPath() ) elif choice == 'no': infoMessage("Skipping update of repository '%s'"%self.getID(), 2) else: ctxAssert( False, "Unhandled choice" ) else: infoMessage("Repository '%s' (%s) is up to date"%(self.getID(), self.getHref()), 1) else: ctxAssert( False, "Unhandled access policy '%d'"%self.getAccessPolicy() )
def getRevisionFromURL( self, url ): url = urllib.quote(url, safe=',~=!@#$%^&*()+|}{:?><;[]\\/') entry = self.client.info2( url ) ctxAssert( entry[0][1]['rev'].kind == pysvn.opt_revision_kind.number, "Revision of URL is not a number" ) return entry[0][1]['rev'].number