gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r743615 - /gump/trunk/python/gump/core/update/updater.py
Date Thu, 12 Feb 2009 04:25:57 GMT
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()            



Mime
View raw message