gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r776566 - in /gump/trunk/python/gump: core/model/repository.py core/update/__init__.py core/update/darcs.py core/update/git.py core/update/scmupdater.py core/update/svn.py core/update/updater.py util/sync.py
Date Wed, 20 May 2009 05:55:37 GMT
Author: bodewig
Date: Wed May 20 05:55:36 2009
New Revision: 776566

URL: http://svn.apache.org/viewvc?rev=776566&view=rev
Log:
darcs support

Added:
    gump/trunk/python/gump/core/update/darcs.py   (contents, props changed)
      - copied, changed from r776535, gump/trunk/python/gump/core/update/git.py
Modified:
    gump/trunk/python/gump/core/model/repository.py
    gump/trunk/python/gump/core/update/__init__.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
    gump/trunk/python/gump/core/update/updater.py
    gump/trunk/python/gump/util/sync.py

Modified: gump/trunk/python/gump/core/model/repository.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/model/repository.py?rev=776566&r1=776565&r2=776566&view=diff
==============================================================================
--- gump/trunk/python/gump/core/model/repository.py (original)
+++ gump/trunk/python/gump/core/model/repository.py Wed May 20 05:55:36 2009
@@ -36,10 +36,11 @@
 SCM_TYPE_ARTIFACTS = ScmType('artifacts', 'Artfifacts')
 SCM_TYPE_P4 = ScmType('p4', 'Perforce')
 SCM_TYPE_GIT = ScmType('git', 'Git')
+SCM_TYPE_DARCS = ScmType('darcs', 'darcs')
 
 # sorted by priority, the first matching SCM element inside a module wins
 SUPPORTED_SCMS = [SCM_TYPE_CVS, SCM_TYPE_SVN, SCM_TYPE_P4,
-                  SCM_TYPE_GIT,
+                  SCM_TYPE_GIT, SCM_TYPE_DARCS,
                   SCM_TYPE_ARTIFACTS]
 
 def scm_type_for_name(name):
@@ -54,7 +55,7 @@
 class Repository(NamedModelObject, Statable):
     """ 
 
-    A named repository (CVS|SVN|Perforce|Artifacts|GIT) 
+    A named repository (CVS|SVN|Perforce|Artifacts|GIT|darcs) 
 
     """
     def __init__(self, name, dom, workspace):

Modified: gump/trunk/python/gump/core/update/__init__.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/__init__.py?rev=776566&r1=776565&r2=776566&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/__init__.py (original)
+++ gump/trunk/python/gump/core/update/__init__.py Wed May 20 05:55:36 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", "scmupdater"]
+__all__ = ["updater","cvs","svn","jars", "git", "scmupdater", "darcs"]
 
     

Copied: gump/trunk/python/gump/core/update/darcs.py (from r776535, gump/trunk/python/gump/core/update/git.py)
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/darcs.py?p2=gump/trunk/python/gump/core/update/darcs.py&p1=gump/trunk/python/gump/core/update/git.py&r1=776535&r2=776566&rev=776566&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/git.py (original)
+++ gump/trunk/python/gump/core/update/darcs.py Wed May 20 05:55:36 2009
@@ -16,30 +16,26 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from gump import log
-from gump.core.update.scmupdater import match_workspace_template, ScmUpdater, \
-    should_be_quiet
+import re
+from gump.core.update.scmupdater import extract_URL, log_repository_and_url, \
+    match_workspace_template, ScmUpdater, should_be_quiet
 from gump.util.process.command import Cmd
-from gump.util.tools import tailFileToString
 
-def log_repository_and_url(module):
-    repository = module.repository
-    url = module.getScm().getRootUrl()
-    log.debug("GIT URL: [" + url + "] on Repository: " + \
-                  repository.getName())
-
-                  
-def maybe_make_quiet(module, cmd):
+def setup_common_parameters(module, cmd):
     if should_be_quiet(module):    
-        cmd.addParameter('--quiet')
+        cmd.addParameter('-q')
+    elif module.isDebug():
+        cmd.addParameter('-v')
+
+URL_REGEX = re.compile('^Default Remote:\s+(.*)\s*$', re.MULTILINE | re.UNICODE)
 
 ###############################################################################
 # Classes
 ###############################################################################
 
-class GitUpdater(ScmUpdater):
+class DarcsUpdater(ScmUpdater):
     """
-    Updater for GIT
+    Updater for darcs
     """
     
     def __init__(self, run):
@@ -48,31 +44,37 @@
 
     def getCheckoutCommand(self, module):
         """
-            Build the appropriate GIT command for clone
+            Build the appropriate darcs command for get
         """
-        log_repository_and_url(module)
-        cmd = Cmd('git-clone', 'update_' + module.getName(), 
+        log_repository_and_url(module, 'darcs')
+        cmd = Cmd('darcs', 'update_' + module.getName(), 
                   module.getWorkspace().getSourceControlStagingDirectory())
-        maybe_make_quiet(module, cmd)
+        cmd.addParameter('get')
+        setup_common_parameters(module, cmd)
         cmd.addParameter(module.getScm().getRootUrl())
         cmd.addParameter(module.getName())
         return cmd
 
     def getUpdateCommand(self, module):
         """
-            Build the appropriate GIT command for pull
+            Build the appropriate darcs command for pull
         """
-        log_repository_and_url(module)
-        cmd = Cmd('git-pull', 'update_' + module.getName(), 
+        log_repository_and_url(module, 'darcs')
+        cmd = Cmd('darcs', 'update_' + module.getName(), 
                   module.getSourceControlStagingDirectory())
-        maybe_make_quiet(module, cmd)
+        cmd.addParameter('pull')
+        setup_common_parameters(module, cmd)
+        # pull everything, don't ask
+        cmd.addParameter('-a')
         return cmd
 
     def workspaceMatchesModule(self, module):
         """
-            Run git config remote.origin.url to see whether the URL matches
+            Run darcs query repo to see whether the URL matches
         """
-        return match_workspace_template(module, 'git config remote.origin.url',
+        return match_workspace_template(module, 'darcs query repo',
                                         lambda result:
-                                            tailFileToString(result.getOutput(),
-                                                             1).rstrip())
+                                            extract_URL(result, URL_REGEX,
+                                                        'darcs query repo'),
+                                        module.getScm().getRootUrl() \
+                                            .rstrip('/'))

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

Propchange: gump/trunk/python/gump/core/update/darcs.py
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: gump/trunk/python/gump/core/update/git.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/git.py?rev=776566&r1=776565&r2=776566&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/git.py (original)
+++ gump/trunk/python/gump/core/update/git.py Wed May 20 05:55:36 2009
@@ -16,19 +16,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from gump import log
 from gump.core.update.scmupdater import match_workspace_template, ScmUpdater, \
-    should_be_quiet
+    should_be_quiet, log_repository_and_url
 from gump.util.process.command import Cmd
 from gump.util.tools import tailFileToString
 
-def log_repository_and_url(module):
-    repository = module.repository
-    url = module.getScm().getRootUrl()
-    log.debug("GIT URL: [" + url + "] on Repository: " + \
-                  repository.getName())
-
-                  
 def maybe_make_quiet(module, cmd):
     if should_be_quiet(module):    
         cmd.addParameter('--quiet')
@@ -50,7 +42,7 @@
         """
             Build the appropriate GIT command for clone
         """
-        log_repository_and_url(module)
+        log_repository_and_url(module, 'git')
         cmd = Cmd('git-clone', 'update_' + module.getName(), 
                   module.getWorkspace().getSourceControlStagingDirectory())
         maybe_make_quiet(module, cmd)
@@ -62,7 +54,7 @@
         """
             Build the appropriate GIT command for pull
         """
-        log_repository_and_url(module)
+        log_repository_and_url(module, 'git')
         cmd = Cmd('git-pull', 'update_' + module.getName(), 
                   module.getSourceControlStagingDirectory())
         maybe_make_quiet(module, cmd)

Modified: gump/trunk/python/gump/core/update/scmupdater.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/scmupdater.py?rev=776566&r1=776565&r2=776566&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/scmupdater.py (original)
+++ gump/trunk/python/gump/core/update/scmupdater.py Wed May 20 05:55:36 2009
@@ -17,6 +17,7 @@
 # limitations under the License.
 
 import os.path
+import StringIO
 
 from gump import log
 
@@ -24,7 +25,7 @@
     REASON_UPDATE_FAILED, STATE_FAILED, STATE_SUCCESS, WORK_TYPE_UPDATE
 from gump.core.run.gumprun import RunSpecific
 from gump.util.process.launcher import execute
-from gump.util.tools import wipeDirectoryTree
+from gump.util.tools import catFile, wipeDirectoryTree
 from gump.util.process.command import getCmdFromString
 
 def should_be_quiet(module):
@@ -61,6 +62,26 @@
     return (expectedURL == actualURL, 'Expected URL \'' + expectedURL + \
                 '\' but working copy was \'' + actualURL + '\'')
 
+def log_repository_and_url(module, scmType):
+    repository = module.repository
+    url = module.getScm().getRootUrl()
+    log.debug(scmType + " URL: [" + url + "] on Repository: " + \
+                  repository.getName())
+
+def extract_URL(result, regex, command):
+    """
+    Extracs the URL from result
+    """
+    stream = StringIO.StringIO()
+    catFile(stream, result.getOutput())
+    output = stream.getvalue()
+    stream.close()
+    match = regex.search(output)
+    if not match:
+        return 'Couldn\'t find URL in ' + command + ' output ' + output
+    return match.group(1)
+
+                  
 ###############################################################################
 # Classes
 ###############################################################################

Modified: gump/trunk/python/gump/core/update/svn.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/svn.py?rev=776566&r1=776565&r2=776566&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/svn.py (original)
+++ gump/trunk/python/gump/core/update/svn.py Wed May 20 05:55:36 2009
@@ -17,13 +17,11 @@
 # limitations under the License.
 
 import re
-import StringIO
 
 from gump import log
 from gump.core.update.scmupdater import match_workspace_template, ScmUpdater, \
-    should_be_quiet
+    should_be_quiet, extract_URL
 from gump.util.process.command import Cmd
-from gump.util.tools import catFile
 
 def getCommand(module, forUpdate):
     """
@@ -75,19 +73,6 @@
 
 URL_REGEX = re.compile('^URL:\s+(.*)\s*$', re.MULTILINE | re.UNICODE)
 
-def extract_URL(result):
-    """
-    Extracs the URL from 'svn info' output
-    """
-    stream = StringIO.StringIO()
-    catFile(stream, result.getOutput())
-    output = stream.getvalue()
-    stream.close()
-    match = URL_REGEX.search(output)
-    if not match:
-        return 'Couldn\'t find URL in svn info output ' + output
-    return match.group(1)
-
 ###############################################################################
 # Classes
 ###############################################################################
@@ -117,6 +102,9 @@
         """
             Run svn info to see whether the URL matches
         """
-        return match_workspace_template(module, 'svn info', extract_URL,
+        return match_workspace_template(module, 'svn info',
+                                        lambda result:
+                                            extract_URL(result, URL_REGEX,
+                                                        'svn info'),
                                         module.getScm().getRootUrl() \
                                             .rstrip('/'))

Modified: gump/trunk/python/gump/core/update/updater.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/updater.py?rev=776566&r1=776565&r2=776566&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/updater.py (original)
+++ gump/trunk/python/gump/core/update/updater.py Wed May 20 05:55:36 2009
@@ -24,13 +24,14 @@
 
 from gump import log
 from gump.core.model.repository import SCM_TYPE_CVS, SCM_TYPE_GIT, \
-    SCM_TYPE_SVN, SCM_TYPE_P4
+    SCM_TYPE_SVN, SCM_TYPE_P4, SCM_TYPE_DARCS
 from gump.core.model.workspace import catFileToFileHolder, \
     EXIT_CODE_FAILED, EXIT_CODE_SUCCESS, FILE_TYPE_LOG, \
     gumpSafeName, logResourceUtilization, \
     STATE_FAILED, STATE_SUCCESS, syncDirectories, REASON_SYNC_FAILED
 from gump.core.run.gumprun import RunSpecific
 from gump.core.update.cvs import CvsUpdater
+from gump.core.update.darcs import DarcsUpdater
 from gump.core.update.git import GitUpdater
 from gump.core.update.p4 import P4Updater
 from gump.core.update.svn import SvnUpdater
@@ -101,7 +102,8 @@
             SCM_TYPE_CVS : CvsUpdater(run),
             SCM_TYPE_SVN : SvnUpdater(run),
             SCM_TYPE_P4 : P4Updater(run),
-            SCM_TYPE_GIT : GitUpdater(run)
+            SCM_TYPE_GIT : GitUpdater(run),
+            SCM_TYPE_DARCS : DarcsUpdater(run)
             }
 
 
@@ -141,7 +143,7 @@
     
         workspace = self.run.getWorkspace()
         
-        log.debug("Workspace CVS|SVN|P4|GIT Directory: " \
+        log.debug("Workspace CVS|SVN|P4|GIT|darcs Directory: " \
                       + workspace.getSourceControlStagingDirectory())
 
         # Update all the modules that have repositories

Modified: gump/trunk/python/gump/util/sync.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/util/sync.py?rev=776566&r1=776565&r2=776566&view=diff
==============================================================================
--- gump/trunk/python/gump/util/sync.py (original)
+++ gump/trunk/python/gump/util/sync.py Wed May 20 05:55:36 2009
@@ -198,8 +198,8 @@
                     linkto = os.readlink(srcname)
                     os.symlink(linkto, dstname)
                 elif os.path.isdir(srcname):
-                    # Copy directories, but not CVS/SVN/GIT stuff
-                    if not name in ['CVS','.svn','.git']:
+                    # Copy directories, but not CVS/SVN/GIT etc. stuff
+                    if not name in ['CVS','.svn','.git', '_darcs']:
                         self.copytree(srcname, dstname, symlinks)
                 else:
                     # Selectively copy file



Mime
View raw message