Return-Path: Delivered-To: apmail-gump-commits-archive@www.apache.org Received: (qmail 88333 invoked from network); 24 Feb 2009 03:46:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Feb 2009 03:46:43 -0000 Received: (qmail 89751 invoked by uid 500); 24 Feb 2009 03:46:43 -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 89742 invoked by uid 99); 24 Feb 2009 03:46:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Feb 2009 19:46:43 -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; Tue, 24 Feb 2009 03:46:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F216C23888A5; Tue, 24 Feb 2009 03:46:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@gump.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090224034621.F216C23888A5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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