Return-Path: Delivered-To: apmail-gump-commits-archive@www.apache.org Received: (qmail 38796 invoked from network); 12 Feb 2009 04:26:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Feb 2009 04:26:30 -0000 Received: (qmail 27965 invoked by uid 500); 12 Feb 2009 04:26:22 -0000 Mailing-List: contact commits-help@gump.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: general@gump.apache.org Delivered-To: mailing list commits@gump.apache.org Received: (qmail 27955 invoked by uid 99); 12 Feb 2009 04:26:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Feb 2009 20:26:22 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Feb 2009 04:26:19 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 450F723888F1; Thu, 12 Feb 2009 04:25:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r743615 - /gump/trunk/python/gump/core/update/updater.py Date: Thu, 12 Feb 2009 04:25:57 -0000 To: commits@gump.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090212042558.450F723888F1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bodewig Date: Thu Feb 12 04:25:57 2009 New Revision: 743615 URL: http://svn.apache.org/viewvc?rev=743615&view=rev Log: reduce some duplication in updater, prepare for more changes Modified: gump/trunk/python/gump/core/update/updater.py Modified: gump/trunk/python/gump/core/update/updater.py URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/updater.py?rev=743615&r1=743614&r2=743615&view=diff ============================================================================== --- gump/trunk/python/gump/core/update/updater.py (original) +++ gump/trunk/python/gump/core/update/updater.py Thu Feb 12 04:25:57 2009 @@ -57,10 +57,9 @@ def __init__(self,run): RunSpecific.__init__(self, run) - self.cvs=CvsUpdater(run) - self.svn=SvnUpdater(run) - self.p4=P4Updater(run) - self.git=GitUpdater(run) + self.updaters = {'cvs' : CvsUpdater(run), 'svn' : SvnUpdater(run), + 'p4' : P4Updater(run), 'git' : GitUpdater(run)} + """ @@ -102,9 +101,10 @@ workspace = self.run.getWorkspace() - log.debug("Workspace CVS|SVN|P4|GIT Directory: " + workspace.getSourceControlStagingDirectory()) + log.debug("Workspace CVS|SVN|P4|GIT Directory: " \ + + workspace.getSourceControlStagingDirectory()) - # Update all the modules that have CVS repositories + # Update all the modules that have repositories for module in list: self.updateModule(module) @@ -124,14 +124,9 @@ if module.okToPerformWork(): ok = 0 - if module.hasCvs(): - ok=self.cvs.updateModule(module) - elif module.hasSvn(): - ok=self.svn.updateModule(module) - if module.hasP4(): - ok=self.p4.updateModule(module) - elif module.hasGit(): - ok=self.git.updateModule(module) + scmUpdater = self.getScmUpdater(module) + if scmUpdater: + scmUpdater.updateModule(module) else: # :TODO: Now what? pass @@ -141,6 +136,20 @@ self.syncModule(module) + def getScmUpdater(self, module): + """ + Finds the correct SCM updater for a given module + """ + if module.hasCvs(): + return self.updaters['cvs'] + elif module.hasSvn(): + return self.updaters['svn'] + elif module.hasP4(): + return self.updaters['p4'] + elif module.hasGit(): + return self.updaters['git'] + return None + def syncModule(self,module): """ @@ -158,15 +167,17 @@ changesFile = os.path.abspath( \ os.path.join( \ workspace.tmpdir, \ - 'changes_to_'+gumpSafeName(module.getName())+'.txt')) + 'changes_to_'\ + + gumpSafeName(module.getName())+'.txt')) # Perform the operation. - (actions,modified,cleaned)=syncDirectories(sourcedir,destdir,module,changesFile) + (actions,modified,cleaned)=syncDirectories(sourcedir,destdir,module, + changesFile) # We are good to go... module.changeState(STATE_SUCCESS) - # Were the contents of the repository modified? + # Were the contents of the repository modified? if modified: # @@ -200,13 +211,8 @@ """ - if module.hasCvs(): - ok=self.cvs.preview(module) - elif module.hasSvn(): - ok=self.svn.preview(module) - elif module.hasP4(): - ok=self.p4.preview(module) - elif module.hasGit(): - ok=self.git.preview(module) + scmUpdater = self.getScmUpdater(module) + if scmUpdater: + scmUpdater.preview(module) else: print 'No updater for module: ' + module.getName()