gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r744794 - in /gump/trunk/python/gump/core/update: __init__.py cvs.py git.py scmupdater.py svn.py
Date Mon, 16 Feb 2009 03:29:01 GMT
Author: bodewig
Date: Mon Feb 16 03:29:00 2009
New Revision: 744794

URL: http://svn.apache.org/viewvc?rev=744794&view=rev
Log:
refactor updaters in order to greatly reduce copy-n-paste

Added:
    gump/trunk/python/gump/core/update/scmupdater.py   (with props)
Modified:
    gump/trunk/python/gump/core/update/__init__.py
    gump/trunk/python/gump/core/update/cvs.py
    gump/trunk/python/gump/core/update/git.py
    gump/trunk/python/gump/core/update/svn.py

Modified: gump/trunk/python/gump/core/update/__init__.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/__init__.py?rev=744794&r1=744793&r2=744794&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/__init__.py (original)
+++ gump/trunk/python/gump/core/update/__init__.py Mon Feb 16 03:29:00 2009
@@ -17,6 +17,6 @@
 # limitations under the License.
 
 # tell Python what modules make up the gump.test package
-__all__ = ["updater","cvs","svn","jars", "git"]
+__all__ = ["updater","cvs","svn","jars", "git", "scmupdater"]
 
     

Modified: gump/trunk/python/gump/core/update/cvs.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/cvs.py?rev=744794&r1=744793&r2=744794&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/cvs.py (original)
+++ gump/trunk/python/gump/core/update/cvs.py Mon Feb 16 03:29:00 2009
@@ -43,189 +43,91 @@
 
 from gump.tool.integration.cvs import *
 
+from gump.core.update.scmupdater import ScmUpdater
 
 ###############################################################################
 # Classes
 ###############################################################################
 
-class CvsUpdater(RunSpecific):
+class CvsUpdater(ScmUpdater):
     
     def __init__(self,run):
-        RunSpecific.__init__(self,run)
+        ScmUpdater.__init__(self,run)
 
         #
         # A stash of known logins.
         #
         self.logins=readLogins()
 
-    def updateModule(self,module):
+    def getCheckoutCommand(self, module):
         """
-        
-            Perform a CVS update on a module
-            
+            Build the appropriate CVS command for checkout
         """
-            
-        #log.info('Perform CVS Update on #[' + `module.getPosition()` + \
-        #                '] : ' + module.getName())
+        self.maybeLogin(module)
     
-        # Did we 'CVS checkout' already?
-        exists	=	os.path.exists(module.getSourceControlStagingDirectory())
-       
-        # Doesn't tell us much...
-        #if exists:
-        #    self.performStatus(module)
-                
-        self.performUpdate(module,exists)        
-        
-        return module.okToPerformWork()      
-        
-    def performStatus(self,module):
-        #  Get the Update Command
-        (repository, root, cmd ) = self.getUpdateCommand(module, True, True)
-                
-        # Provide CVS logins, if not already there
-        loginToRepositoryOnDemand(repository,root,self.logins)
-               
-        # Execute the command and capture results        
-        cmdResult=execute(cmd, module.getWorkspace().tmpdir)
-      
-        #
-        # Store this as work, on both the module and (cloned) on the repo
-        #
-        work=CommandWorkItem(WORK_TYPE_UPDATE,cmd,cmdResult)
-        module.performedWork(work)  
-     
-        if not cmdResult.isOk():              
-            log.error('Failed to checkout/update module: ' + module.name)   
-                                  
-    def performUpdate(self,module,exists):
-        """
-            Update this module (checking out if needed)
-        """
-        #  Get the Update Command
-        (repository, root, cmd ) = self.getUpdateCommand(module, exists)
-                
-        #log.debug("CVS Update Module " + module.getName() + \
-        #               ", Repository Name: " + str(module.repository.getName()))
-                                        
-        # Provide CVS logins, if not already there
-        loginToRepositoryOnDemand(repository,root,self.logins)
-               
-        # Execute the command and capture results        
-        cmdResult=execute(cmd, module.getWorkspace().tmpdir)
-      
-        #
-        # Store this as work, on both the module and (cloned) on the repo
-        #
-        work=CommandWorkItem(WORK_TYPE_UPDATE,cmd,cmdResult)
-        module.performedWork(work)  
-        repository.performedWork(work.clone())
-      
-        # Update Context w/ Results  
-        if not cmdResult.isOk():              
-            log.error('Failed w/ CVS Root ' + root + ' for %s on Repository %s.' \
-                % (module.name, module.repository.getName())) 
-            module.changeState(STATE_FAILED,REASON_UPDATE_FAILED)
+        cmd = Cmd('cvs', 'update_' + module.getName(),
+                  module.getWorkspace().getSourceControlStagingDirectory())
+        self.setupCommonParameters(module, cmd)
+          
+        # do a cvs checkout
+        cmd.addParameter('checkout')
+        cmd.addParameter('-P')
+        self.maybeAddTag(module, cmd)
+
+        if not module.getScm().hasModule() or \
+           not module.getScm().getModule() == module.getName(): 
+            cmd.addParameter('-d', module.getName(), ' ')
+
+        if module.getScm().hasModule():
+            cmd.addParameter(module.getScm().getModule())
         else:
-            module.changeState(STATE_SUCCESS)      
-            
-            # We run CVS as -q (quiet) so any output means
-            # updates occured...
-            if cmdResult.hasOutput():                       
-                log.info('Update(s) received via CVS on #[' \
-                                + `module.getPosition()` + \
-                                '] : ' + module.getName())
-                                 
-    def preview(self,module):
-                
-        (repository, root, command ) = self.getUpdateCommand(module,False)
-        command.dump()
-        
-        # Doesn't tell us much...
-        #(repository, root, command ) = self.getUpdateCommand(module,True,True)
-        #command.dump()
-            
-        (repository, root, command ) = self.getUpdateCommand(module,True)
-        command.dump()                       
-        
-    
-    def getUpdateCommand(self,module,exists=False,nowork=False):
-        """        
-            Format a commandline for doing the CVS update            
+            cmd.addParameter(module.getName())            
+
+        return cmd
+
+    def getUpdateCommand(self, module):
+        """
+            Build the appropriate CVS command for update
         """
-        
-        if nowork and not exists:
-            raise RuntimeException('Not coded for this combo.')            
-        
-        root=module.getScm().getCvsRoot()
+
+        self.maybeLogin(module)
     
-        # Prepare CVS checkout/update command...
-        prefix='update'
-        directory=module.getWorkspace().getSourceControlStagingDirectory()
-        if exists:     
-            directory=module.getSourceControlStagingDirectory()            
-        if nowork:
-            prefix='status'       
-                
-        cmd=Cmd(	'cvs',
-                    prefix+'_'+module.getName(),
-                    directory)
+        cmd = Cmd('cvs', 'update_' + module.getName(),
+                  module.getSourceControlStagingDirectory())
+        self.setupCommonParameters(module, cmd)
           
-        # Be 'quiet' (but not silent) unless requested otherwise.
-        if 	not module.isDebug() 	\
-            and not module.isVerbose() \
-            and not module.getScm().isDebug()	\
-            and not module.getScm().isVerbose():    
+        # Do a cvs update
+        cmd.addParameter('update')
+        cmd.addParameter('-P')
+        cmd.addParameter('-d')
+        self.maybeAddTag(module, cmd)
+
+        return cmd
+    
+    def setupCommonParameters(self, module, cmd):
+        if self.shouldBeQuiet(module):    
             cmd.addParameter('-q')
-        
-        if nowork:
-            cmd.addParameter('-n')
-          
-        # Allow trace for debug
-        if module.isDebug():
+        elif module.isDebug():
             cmd.addParameter('-t')
-          
         # Request compression
         cmd.addParameter('-z3')
           
         # Set the CVS root
-        cmd.addParameter('-d', root)
-    
+        cmd.addParameter('-d', module.getScm().getCvsRoot())    
+
+    def maybeLogin(self, module):
+        repository = module.repository
+        root = module.getScm().getCvsRoot()
+
+        # Provide CVS logins, if not already there
+        loginToRepositoryOnDemand(repository, root, self.logins)
+
+    def maybeAddTag(self, module, cmd):
         # Determine if a tag is set, on <cvs or on <module
-        tag=None
+        tag = None
         if module.getScm().hasTag():
-            tag=module.getScm().getTag()
+            tag = module.getScm().getTag()
         elif module.hasTag():
-            tag=module.getTag()
-            
-        if exists:
-
-            # Do a cvs update
-            cmd.addParameter('update')
-            cmd.addParameter('-P')
-            cmd.addParameter('-d')
-            if tag:
-                cmd.addParameter('-r',tag,' ')
-            else:
-                cmd.addParameter('-A')
-            #cmd.addParameter(module.getName())
-
-        else:
-
-            # do a cvs checkout
-            cmd.addParameter('checkout')
-            cmd.addParameter('-P')
-            if tag:
-                cmd.addParameter('-r',tag,' ')
-
-            if 	not module.getScm().hasModule() or \
-                not module.getScm().getModule() == module.getName(): 
-                    cmd.addParameter('-d',module.getName(),' ')
-                    
-            if module.getScm().hasModule():
-                cmd.addParameter(module.getScm().getModule())
-            else:
-                cmd.addParameter(module.getName())            
-        
-        return (module.repository, root, cmd)
-    
+            tag = module.getTag()
+        if tag:
+            cmd.addParameter('-r', tag, ' ')

Modified: gump/trunk/python/gump/core/update/git.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/git.py?rev=744794&r1=744793&r2=744794&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/git.py (original)
+++ gump/trunk/python/gump/core/update/git.py Mon Feb 16 03:29:00 2009
@@ -42,165 +42,47 @@
 from gump.core.model.stats import *
 from gump.core.model.state import *
 
+from gump.core.update.scmupdater import ScmUpdater
+
 ###############################################################################
 # Classes
 ###############################################################################
 
-class GitUpdater(RunSpecific):
+class GitUpdater(ScmUpdater):
     
     def __init__(self,run):
-        RunSpecific.__init__(self,run)
+        ScmUpdater.__init__(self,run)
 
 
-    def updateModule(self,module):
-        """        
-            Perform a GIT update on a module            
-        """
-            
-        log.info('Perform GIT Update on #[' + `module.getPosition()` + \
-                        '] : ' + module.getName())
-    
-        # Did we 'GIT checkout' already?
-        exists	=	os.path.exists(module.getSourceControlStagingDirectory())
-       
-        self.performUpdate(module, exists)
-        
-        return module.okToPerformWork()   
-              
-    def performStatus(self,module):
+    def getCheckoutCommand(self, module):
         """
-        
-            Do a status comparison between our copy and server
-            
+            Build the appropriate GIT command for clone
         """
-        
-        # need to look up how to do that with git
+        self.logRepositoryAndURL(module)
+        cmd = Cmd('git-clone', 'update_' + module.getName(), 
+                  module.getWorkspace().getSourceControlStagingDirectory())
+        self.maybeMakeQuiet(module, cmd)
+        cmd.addParameter(module.getScm().getRootUrl())
+        cmd.addParameter(module.getName())
+        return cmd
 
-    def getStatusCommand(self,module):
+    def getUpdateCommand(self, module):
         """
-        
-            Build the 'git status --show-updates --non-interative' command
-            
+            Build the appropriate GIT command for pull
         """
-
-        # need to look up how to do that with git, this is certainly wrong
-
-        log.debug("Git Module Status : " + module.getName() + \
-                       ", Repository Name: " + str(module.repository.getName()))
-                                        
-        url=module.getScm().getRootUrl()
-      
-        log.debug("GIT URL: [" + url + "] on Repository: " + module.repository.getName())
-     
-        #
-        # Prepare GIT checkout/update command...
-        # 
-        cmd=Cmd('git', 'status_'+module.getName(), 
-                module.getSourceControlStagingDirectory())
-       
-        #
-        # Be 'quiet' (but not silent) unless requested otherwise.
-        #
-        if 	not module.isDebug() 	\
-            and not module.isVerbose() \
-            and not module.getScm().isDebug()	\
-            and not module.getScm().isVerbose():    
-            cmd.addParameter('--quiet')
-                  
-        #
-        # Allow trace for debug
-        #
-        # if module.isDebug() or  module.getScm().isDebug():
-        #    cmd.addParameter('--verbose')
-            
-        # do an GIT status
-        cmd.addParameter('status')
-       
+        self.logRepositoryAndURL(module)
+        cmd = Cmd('git-pull', 'update_' + module.getName(), 
+                  module.getSourceControlStagingDirectory())
+        self.maybeMakeQuiet(module, cmd)
         return cmd
 
-                                                  
-    def performUpdate(self,module,exists):
-        """
-        
-            Clone or Pull  from GIT
-            
-        """
-        
-        #  Get the Update Command
-        (repository, url, cmd ) = self.getUpdateCommand(module, exists)
-                
-               
-        # Execute the command and capture results        
-        cmdResult=execute(cmd, module.getWorkspace().tmpdir)
-      
-        #
-        # Store this as work, on both the module and (cloned) on the repo
-        #
-        work=CommandWorkItem(WORK_TYPE_UPDATE,cmd,cmdResult)
-        module.performedWork(work)  
-        repository.performedWork(work.clone())
-      
-        # Update Context w/ Results  
-        if not cmdResult.isOk():              
-            log.error('Failed to clone/pull module: ' + module.name)   
-            module.changeState(STATE_FAILED,REASON_UPDATE_FAILED)
-        else:
-            module.changeState(STATE_SUCCESS)       
-                         
-                             
-    def preview(self,module):
-        (repository, url, command ) = self.getUpdateCommand(module,0)
-        command.dump()
-          
-        (repository, url, command ) = self.getUpdateCommand(module,1)
-        command.dump()                                            
-    
-    def getUpdateCommand(self,module,exists=0):
-        """
-            Build the appropriate GIT command for clone/pull
-        """
-        repository=module.repository
-        
-        log.debug("Git Module Update : " + module.getName() + \
-                       ", Repository Name: " + repository.getName())
-                                        
-        url=module.getScm().getRootUrl()
-      
-        log.debug("GIT URL: [" + url + "] on Repository: " + repository.getName())
-     
-        #
-        # Prepare GIT clone/pull command...
-        # 
-       
-        if exists:
-            # do a GIT pull inside working copy
-            cmd=Cmd('git-pull', 'update_'+module.getName(), 
-                    module.getSourceControlStagingDirectory())
-        else:
-            # do a GIT clone
-            cmd=Cmd('git-clone', 'update_'+module.getName(), 
-                    module.getWorkspace().getSourceControlStagingDirectory())
-       
-        #
-        # Be 'quiet' (but not silent) unless requested otherwise.
-        #
-        if 	not module.isDebug() 	\
-            and not module.isVerbose() \
-            and not module.getScm().isDebug()	\
-            and not module.getScm().isVerbose():    
+    def logRepositoryAndURL(self, module):
+        repository = module.repository
+        url = module.getScm().getRootUrl()
+        log.debug("GIT URL: [" + url + "] on Repository: " + \
+                      repository.getName())
+
+    def maybeMakeQuiet(self, module, cmd):
+        if self.shouldBeQuiet(module):    
             cmd.addParameter('--quiet')
                   
-        #
-        # Allow trace for debug
-        #
-        # if module.isDebug() or  module.getScm().isDebug():
-        #    cmd.addParameter('--verbose')
-            
-        if not exists:
-            # do an GIT pull
-            cmd.addParameter(url)
-            cmd.addParameter(module.getName())
-
-        return (module.repository, url, cmd)
-         
-    

Added: gump/trunk/python/gump/core/update/scmupdater.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/scmupdater.py?rev=744794&view=auto
==============================================================================
--- gump/trunk/python/gump/core/update/scmupdater.py (added)
+++ gump/trunk/python/gump/core/update/scmupdater.py Mon Feb 16 03:29:00 2009
@@ -0,0 +1,148 @@
+#!/usr/bin/python
+
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+# 
+#     http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os.path
+import sys
+
+from gump import log
+
+from gump.core.run.gumprun import *
+from gump.util.note import Annotatable
+from gump.core.model.workspace import *
+from gump.core.model.module import Module
+from gump.core.model.stats import *
+from gump.core.model.state import *
+
+###############################################################################
+# Classes
+###############################################################################
+class ScmUpdater(RunSpecific):
+    """
+    Base class for a SCM specific updaters.
+    
+    Provides helpers and template method implementations.
+    """
+    
+    def __init__(self,run):
+        RunSpecific.__init__(self, run)
+
+    #
+    # "public" interface of ScmUpdater
+    #
+
+    def preview(self, module):
+        """
+        Supposed to preview what needs to be done.
+
+        For most SCMs it doesn't say much and this method is never
+        called during a normal Gump run.
+        """
+        (cmd, isUpdate) = self.getCommandAndType(module)
+        if cmd:
+            cmd.dump()
+
+    def updateModule(self, module):
+        """
+        Performs a fresh check-out or an update of an existing wrokspace.
+        """
+
+        log.info('Perform ' + module.getScm().getScmName() + \
+                     ' Checkout/Update on #[' + `module.getPosition()` + \
+                     '] : ' + module.getName())
+    
+        (cmd, isUpdate) = self.getCommandAndType(module)
+
+        if cmd:
+            if isUpdate:
+                log.debug(module.getScm().getScmName() + " Module Update : " +\
+                              module.getName() + ", Repository Name: " + \
+                              module.repository.getName())
+            else:
+                log.debug(module.getScm().getScmName() + " Module Checkout : " +\
+                              module.getName() + ", Repository Name: " + \
+                              module.repository.getName())
+
+            # Execute the command and capture results        
+            cmdResult = execute(cmd, module.getWorkspace().tmpdir)
+      
+            # Store this as work, on both the module and (cloned) on the repo
+            work = CommandWorkItem(WORK_TYPE_UPDATE, cmd, cmdResult)
+            module.performedWork(work)
+            module.repository.performedWork(work.clone())
+      
+            # Update Context w/ Results  
+            if not cmdResult.isOk():              
+                log.error('Failed to checkout/update module: ' + module.name)   
+                module.changeState(STATE_FAILED, REASON_UPDATE_FAILED)
+            else:
+                module.changeState(STATE_SUCCESS)       
+
+            return module.okToPerformWork()
+
+        log.error("Don't know how to to checkout/update module: " + module.name)   
+        module.changeState(STATE_FAILED, REASON_UPDATE_FAILED)
+        return False
+
+    #
+    # helpers
+    #
+
+    def shouldBeQuiet(self, module):
+        """
+        Whether the configuration asks for a quiet update
+        (it does so by default)
+        """
+        return not module.isDebug() \
+            and not module.isVerbose() \
+            and not module.getScm().isDebug() \
+            and not module.getScm().isVerbose()
+
+
+    def getCommandAndType(self, module):
+        """
+        Checks whether an update or a fresh checkout is needed and
+        returns a command to perform the required action.
+        
+        Returns a tuple (command, isUpdate)
+        """
+        exists = os.path.exists(module.getSourceControlStagingDirectory())
+
+        cmd = None
+        if exists:
+            cmd = self.getUpdateCommand(module)
+        else:
+            cmd = self.getCheckoutCommand(module)
+        return (cmd, exists)
+
+
+    #
+    # methods that should be overridden in subclasses
+    #
+
+    def getCheckoutCommand(self, module):
+        """
+        Create the command needed to obtain a fresh working copy.
+        """
+        return None
+
+    def getUpdateCommand(self, module):
+        """
+        Create the command needed to update an existing working copy.
+        """
+        return None
+

Propchange: gump/trunk/python/gump/core/update/scmupdater.py
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: gump/trunk/python/gump/core/update/svn.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/svn.py?rev=744794&r1=744793&r2=744794&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/svn.py (original)
+++ gump/trunk/python/gump/core/update/svn.py Mon Feb 16 03:29:00 2009
@@ -42,158 +42,39 @@
 from gump.core.model.stats import *
 from gump.core.model.state import *
 
+from gump.core.update.scmupdater import ScmUpdater
+
 ###############################################################################
 # Classes
 ###############################################################################
 
-class SvnUpdater(RunSpecific):
+class SvnUpdater(ScmUpdater):
     
     def __init__(self,run):
-        RunSpecific.__init__(self,run)
+        ScmUpdater.__init__(self,run)
 
 
-    def updateModule(self,module):
-        """        
-            Perform a SVN update on a module            
-        """
-            
-        log.info('Perform SVN Update on #[' + `module.getPosition()` + \
-                        '] : ' + module.getName())
-    
-        # Did we 'SVN checkout' already?
-        exists	=	os.path.exists(module.getSourceControlStagingDirectory())
-       
-        # Doesn't teach us much
-        #if exists:
-        #    self.performStatus(module)
-            
-        self.performUpdate(module, exists)
-        
-        return module.okToPerformWork()   
-              
-    def performStatus(self,module):
+    def getCheckoutCommand(self, module):
         """
-        
-            Do a status comparison between our copy and server
-            
+            Build the appropriate SVN command for checkout
         """
-        
-        #  Get the Update Command
-        cmd = self.getStatusCommand(module)
-                               
-        # Execute the command and capture results        
-        cmdResult=execute(cmd, module.getWorkspace().tmpdir)
-    
-        # Store this as work
-        work=CommandWorkItem(WORK_TYPE_UPDATE,cmd,cmdResult)
-        module.performedWork(work)  
-      
-        # Update Context w/ Results  
-        if not cmdResult.isOk():              
-            message='Failed to \'status --show-updates\' module: ' + module.getName()
-            module.addWarning(message)
-            log.error(message)               
+        return self.getCommand(module, False)
 
-    def getStatusCommand(self,module):
+    def getUpdateCommand(self, module):
         """
-        
-            Build the 'svn status --show-updates --non-interative' command
-            
+            Build the appropriate SVN command for update
         """
-        log.debug("SubVersion Module Status : " + module.getName() + \
-                       ", Repository Name: " + str(module.repository.getName()))
-                                        
-        url=module.getScm().getRootUrl()
-      
-        log.debug("SVN URL: [" + url + "] on Repository: " + module.repository.getName())
-     
-        #
-        # Prepare SVN checkout/update command...
-        # 
-        cmd=Cmd('svn', 'status_'+module.getName(), 
-                module.getSourceControlStagingDirectory())
-       
-        #
-        # Be 'quiet' (but not silent) unless requested otherwise.
-        #
-        if 	not module.isDebug() 	\
-            and not module.isVerbose() \
-            and not module.getScm().isDebug()	\
-            and not module.getScm().isVerbose():    
-            cmd.addParameter('--quiet')
-                  
-        #
-        # Allow trace for debug
-        #
-        # SVN complains about -v|--verbose, don't ask me why
-        #
-        # if module.isDebug() or  module.svn.isDebug():
-        #    cmd.addParameter('--verbose')
-            
-        # do an SVN status --show-updates
-        cmd.addParameter('status')
-        cmd.addParameter('--show-updates')
-       
-        #
-        # Request non-interactive
-        #
-        cmd.addParameter('--non-interactive')
-
-        return cmd
+        return self.getCommand(module, True)
 
-                                                  
-    def performUpdate(self,module,exists):
+    def getCommand(self, module, forUpdate):
         """
-        
-            Check-out or Update  from SVN
-            
+            Build the appropriate SVN command for checkout or update
         """
-        
-        #  Get the Update Command
-        (repository, url, cmd ) = self.getUpdateCommand(module, exists)
-                
-               
-        # Execute the command and capture results        
-        cmdResult=execute(cmd, module.getWorkspace().tmpdir)
-      
-        #
-        # Store this as work, on both the module and (cloned) on the repo
-        #
-        work=CommandWorkItem(WORK_TYPE_UPDATE,cmd,cmdResult)
-        module.performedWork(work)  
-        repository.performedWork(work.clone())
+        repository = module.repository
+        url = module.getScm().getRootUrl()
       
-        # Update Context w/ Results  
-        if not cmdResult.isOk():              
-            log.error('Failed to checkout/update module: ' + module.name)   
-            module.changeState(STATE_FAILED,REASON_UPDATE_FAILED)
-        else:
-            module.changeState(STATE_SUCCESS)       
-                         
-                             
-    def preview(self,module):
-        (repository, url, command ) = self.getUpdateCommand(module,0)
-        command.dump()
-          
-        # Doesn't teach us much  
-        # command = self.getStatusCommand(module)
-        # command.dump()
-            
-        (repository, url, command ) = self.getUpdateCommand(module,1)
-        command.dump()                                            
-    
-    def getUpdateCommand(self,module,exists=0):
-        """
-            Build the appropriate SVN command for checkout/update
-        """
-        repository=module.repository
-        
-        log.debug("SubVersion Module Update : " + module.getName() + \
-                       ", Repository Name: " + repository.getName())
-                                        
-        url=module.getScm().getRootUrl()
-      
-        log.debug("SVN URL: [" + url + "] on Repository: " + repository.getName())
+        log.debug("SVN URL: [" + url + "] on Repository: "\
+                      + repository.getName())
      
         #
         # Prepare SVN checkout/update command...
@@ -204,25 +85,12 @@
         #
         # Be 'quiet' (but not silent) unless requested otherwise.
         #
-        if 	not module.isDebug() 	\
-            and not module.isVerbose() \
-            and not module.getScm().isDebug()	\
-            and not module.getScm().isVerbose():    
+        if self.shouldBeQuiet(module):    
             cmd.addParameter('--quiet')
                   
-        #
-        # Allow trace for debug
-        #
-        # SVN complains about -v|--verbose, don't ask me why
-        #
-        # if module.isDebug() or  module.getScm().isDebug():
-        #    cmd.addParameter('--verbose')
-            
-        if exists:
-            # do an SVN update
+        if forUpdate:
             cmd.addParameter('update')
         else:
-            # do an SVN checkout
             cmd.addParameter('checkout', url)
        
         #
@@ -244,6 +112,4 @@
            not module.getScm().getDir() == module.getName():
                 cmd.addParameter(module.getName())
         
-        return (module.repository, url, cmd)
-         
-    
+        return cmd



Mime
View raw message