gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r747270 - in /gump/trunk/python/gump/core/update: cvs.py git.py scmupdater.py svn.py
Date Tue, 24 Feb 2009 03:46:21 GMT
Author: bodewig
Date: Tue Feb 24 03:46:21 2009
New Revision: 747270

URL: http://svn.apache.org/viewvc?rev=747270&view=rev
Log:
some method to function refactoring

Modified:
    gump/trunk/python/gump/core/update/cvs.py
    gump/trunk/python/gump/core/update/git.py
    gump/trunk/python/gump/core/update/scmupdater.py
    gump/trunk/python/gump/core/update/svn.py

Modified: gump/trunk/python/gump/core/update/cvs.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/cvs.py?rev=747270&r1=747269&r2=747270&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/cvs.py (original)
+++ gump/trunk/python/gump/core/update/cvs.py Tue Feb 24 03:46:21 2009
@@ -16,7 +16,7 @@
 # limitations under the License.
 
 from gump.core.model.workspace import Cmd
-from gump.core.update.scmupdater import ScmUpdater
+from gump.core.update.scmupdater import ScmUpdater, should_be_quiet
 from gump.tool.integration.cvs import readLogins, loginToRepositoryOnDemand
 
 def maybe_add_tag(module, cmd):
@@ -29,6 +29,18 @@
     if tag:
         cmd.addParameter('-r', tag, ' ')
 
+def setup_common_parameters(module, cmd):
+    if should_be_quiet(module):    
+        cmd.addParameter('-q')
+    elif module.isDebug():
+        cmd.addParameter('-t')
+    # Request compression
+    cmd.addParameter('-z3')
+          
+    # Set the CVS root
+    cmd.addParameter('-d', module.getScm().getCvsRoot())    
+
+
 ###############################################################################
 # Classes
 ###############################################################################
@@ -54,7 +66,7 @@
     
         cmd = Cmd('cvs', 'update_' + module.getName(),
                   module.getWorkspace().getSourceControlStagingDirectory())
-        self.setupCommonParameters(module, cmd)
+        setup_common_parameters(module, cmd)
           
         # do a cvs checkout
         cmd.addParameter('checkout')
@@ -81,7 +93,7 @@
     
         cmd = Cmd('cvs', 'update_' + module.getName(),
                   module.getSourceControlStagingDirectory())
-        self.setupCommonParameters(module, cmd)
+        setup_common_parameters(module, cmd)
           
         # Do a cvs update
         cmd.addParameter('update')
@@ -91,17 +103,6 @@
 
         return cmd
     
-    def setupCommonParameters(self, module, cmd):
-        if self.shouldBeQuiet(module):    
-            cmd.addParameter('-q')
-        elif module.isDebug():
-            cmd.addParameter('-t')
-        # Request compression
-        cmd.addParameter('-z3')
-          
-        # Set the CVS root
-        cmd.addParameter('-d', module.getScm().getCvsRoot())    
-
     def maybeLogin(self, module):
         repository = module.repository
         root = module.getScm().getCvsRoot()

Modified: gump/trunk/python/gump/core/update/git.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/git.py?rev=747270&r1=747269&r2=747270&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/git.py (original)
+++ gump/trunk/python/gump/core/update/git.py Tue Feb 24 03:46:21 2009
@@ -18,7 +18,7 @@
 
 from gump import log
 from gump.core.model.workspace import Cmd
-from gump.core.update.scmupdater import ScmUpdater
+from gump.core.update.scmupdater import ScmUpdater, should_be_quiet
 
 def log_repository_and_url(module):
     repository = module.repository
@@ -27,6 +27,10 @@
                   repository.getName())
 
                   
+def maybe_make_quiet(module, cmd):
+    if should_be_quiet(module):    
+        cmd.addParameter('--quiet')
+
 ###############################################################################
 # Classes
 ###############################################################################
@@ -47,7 +51,7 @@
         log_repository_and_url(module)
         cmd = Cmd('git-clone', 'update_' + module.getName(), 
                   module.getWorkspace().getSourceControlStagingDirectory())
-        self.maybeMakeQuiet(module, cmd)
+        maybe_make_quiet(module, cmd)
         cmd.addParameter(module.getScm().getRootUrl())
         cmd.addParameter(module.getName())
         return cmd
@@ -59,9 +63,5 @@
         log_repository_and_url(module)
         cmd = Cmd('git-pull', 'update_' + module.getName(), 
                   module.getSourceControlStagingDirectory())
-        self.maybeMakeQuiet(module, cmd)
+        maybe_make_quiet(module, cmd)
         return cmd
-
-    def maybeMakeQuiet(self, module, cmd):
-        if self.shouldBeQuiet(module):    
-            cmd.addParameter('--quiet')

Modified: gump/trunk/python/gump/core/update/scmupdater.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/scmupdater.py?rev=747270&r1=747269&r2=747270&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/scmupdater.py (original)
+++ gump/trunk/python/gump/core/update/scmupdater.py Tue Feb 24 03:46:21 2009
@@ -24,6 +24,17 @@
     REASON_UPDATE_FAILED, STATE_FAILED, STATE_SUCCESS, WORK_TYPE_UPDATE
 from gump.core.run.gumprun import RunSpecific
 
+def should_be_quiet(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()
+
+
 ###############################################################################
 # Classes
 ###############################################################################
@@ -101,17 +112,6 @@
     # 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

Modified: gump/trunk/python/gump/core/update/svn.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/svn.py?rev=747270&r1=747269&r2=747270&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/svn.py (original)
+++ gump/trunk/python/gump/core/update/svn.py Tue Feb 24 03:46:21 2009
@@ -18,7 +18,55 @@
 
 from gump import log
 from gump.core.model.workspace import Cmd
-from gump.core.update.scmupdater import ScmUpdater
+from gump.core.update.scmupdater import ScmUpdater, should_be_quiet
+
+def getCommand(module, forUpdate):
+    """
+    Build the appropriate SVN command for checkout or update
+    """
+    repository = module.repository
+    url = module.getScm().getRootUrl()
+      
+    log.debug("SVN URL: [" + url + "] on Repository: "\
+                  + repository.getName())
+     
+    #
+    # Prepare SVN checkout/update command...
+    # 
+    cmd = Cmd('svn', 'update_'+module.getName(), 
+              module.getWorkspace().getSourceControlStagingDirectory())
+       
+    #
+    # Be 'quiet' (but not silent) unless requested otherwise.
+    #
+    if should_be_quiet(module):    
+        cmd.addParameter('--quiet')
+                  
+    if forUpdate:
+        cmd.addParameter('update')
+    else:
+        cmd.addParameter('checkout', url)
+       
+    #
+    # Request non-interactive
+    #
+    cmd.addParameter('--non-interactive')
+
+    # Optional username/password
+    if repository.hasUser():
+        cmd.addParameter('--username', repository.getUser())    
+    if repository.hasPassword():
+        cmd.addParameter('--password', repository.getPassword())
+            
+    #
+    # If module name != SVN directory, tell SVN to put it into
+    # a directory named after our module
+    #
+    if not module.getScm().hasDir() or \
+            not module.getScm().getDir() == module.getName():
+        cmd.addParameter(module.getName())
+        
+    return cmd
 
 ###############################################################################
 # Classes
@@ -37,58 +85,11 @@
         """
             Build the appropriate SVN command for checkout
         """
-        return self.getCommand(module, False)
+        return getCommand(module, False)
 
     def getUpdateCommand(self, module):
         """
             Build the appropriate SVN command for update
         """
-        return self.getCommand(module, True)
+        return getCommand(module, True)
 
-    def getCommand(self, module, forUpdate):
-        """
-            Build the appropriate SVN command for checkout or update
-        """
-        repository = module.repository
-        url = module.getScm().getRootUrl()
-      
-        log.debug("SVN URL: [" + url + "] on Repository: "\
-                      + repository.getName())
-     
-        #
-        # Prepare SVN checkout/update command...
-        # 
-        cmd = Cmd('svn', 'update_'+module.getName(), 
-                  module.getWorkspace().getSourceControlStagingDirectory())
-       
-        #
-        # Be 'quiet' (but not silent) unless requested otherwise.
-        #
-        if self.shouldBeQuiet(module):    
-            cmd.addParameter('--quiet')
-                  
-        if forUpdate:
-            cmd.addParameter('update')
-        else:
-            cmd.addParameter('checkout', url)
-       
-        #
-        # Request non-interactive
-        #
-        cmd.addParameter('--non-interactive')
-
-        # Optional username/password
-        if repository.hasUser():
-            cmd.addParameter('--username', repository.getUser())    
-        if repository.hasPassword():
-            cmd.addParameter('--password', repository.getPassword())
-            
-        #
-        # If module name != SVN directory, tell SVN to put it into
-        # a directory named after our module
-        #
-        if not module.getScm().hasDir() or \
-           not module.getScm().getDir() == module.getName():
-                cmd.addParameter(module.getName())
-        
-        return cmd



Mime
View raw message