Package buildslave :: Package commands :: Module cvs
[frames] | no frames]

Source Code for Module buildslave.commands.cvs

  1  # This file is part of Buildbot.  Buildbot is free software: you can 
  2  # redistribute it and/or modify it under the terms of the GNU General Public 
  3  # License as published by the Free Software Foundation, version 2. 
  4  # 
  5  # This program is distributed in the hope that it will be useful, but WITHOUT 
  6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
  7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
  8  # details. 
  9  # 
 10  # You should have received a copy of the GNU General Public License along with 
 11  # this program; if not, write to the Free Software Foundation, Inc., 51 
 12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
 13  # 
 14  # Copyright Buildbot Team Members 
 15   
 16  import os 
 17  import time 
 18   
 19  from buildslave.commands.base import SourceBaseCommand 
 20  from buildslave import runprocess 
 21   
22 -class CVS(SourceBaseCommand):
23 """CVS-specific VC operation. In addition to the arguments handled by 24 SourceBaseCommand, this command reads the following keys: 25 26 ['cvsroot'] (required): the CVSROOT repository string 27 ['cvsmodule'] (required): the module to be retrieved 28 ['branch']: a '-r' tag or branch name to use for the checkout/update 29 ['login']: a string for use as a password to 'cvs login' 30 ['global_options']: a list of strings to use before the CVS verb 31 ['checkout_options']: a list of strings to use after checkout, 32 but before revision and branch specifiers 33 ['checkout_options']: a list of strings to use after export, 34 but before revision and branch specifiers 35 ['extra_options']: a list of strings to use after export and checkout, 36 but before revision and branch specifiers 37 """ 38 39 header = "cvs operation" 40
41 - def setup(self, args):
42 SourceBaseCommand.setup(self, args) 43 self.cvsroot = args['cvsroot'] 44 self.cvsmodule = args['cvsmodule'] 45 self.global_options = args.get('global_options', []) 46 self.checkout_options = args.get('checkout_options', []) 47 self.export_options = args.get('export_options', []) 48 self.extra_options = args.get('extra_options', []) 49 self.branch = args.get('branch') 50 self.login = args.get('login') 51 self.sourcedata = "%s\n%s\n%s\n" % (self.cvsroot, self.cvsmodule, 52 self.branch)
53
54 - def sourcedirIsUpdateable(self):
55 return (not self.sourcedirIsPatched() and 56 os.path.isdir(os.path.join(self.builder.basedir, 57 self.srcdir, "CVS")))
58
59 - def start(self):
60 cvs = self.getCommand("cvs") 61 if self.login is not None: 62 # need to do a 'cvs login' command first 63 d = self.builder.basedir 64 command = ([cvs, '-d', self.cvsroot] + self.global_options 65 + ['login']) 66 c = runprocess.RunProcess(self.builder, command, d, 67 sendRC=False, timeout=self.timeout, 68 maxTime=self.maxTime, 69 initialStdin=self.login+"\n", 70 logEnviron=self.logEnviron,usePTY=False) 71 self.command = c 72 d = c.start() 73 d.addCallback(self._abandonOnFailure) 74 d.addCallback(self._didLogin) 75 return d 76 else: 77 return self._didLogin(None)
78
79 - def _didLogin(self, res):
80 # now we really start 81 return SourceBaseCommand.start(self)
82
83 - def doVCUpdate(self):
84 cvs = self.getCommand("cvs") 85 d = os.path.join(self.builder.basedir, self.srcdir) 86 command = [cvs, '-z3'] + self.global_options + ['update', '-dP'] 87 if self.branch: 88 command += ['-r', self.branch] 89 if self.revision: 90 command += ['-D', self.revision] 91 c = runprocess.RunProcess(self.builder, command, d, 92 sendRC=False, timeout=self.timeout, 93 maxTime=self.maxTime, logEnviron=self.logEnviron, 94 usePTY=False) 95 self.command = c 96 return c.start()
97
98 - def doVCFull(self):
99 cvs = self.getCommand("cvs") 100 d = self.builder.basedir 101 if self.mode == "export": 102 verb = "export" 103 else: 104 verb = "checkout" 105 command = ([cvs, '-d', self.cvsroot, '-z3'] + 106 self.global_options + 107 [verb, '-d', self.srcdir]) 108 109 if verb == "checkout": 110 command += self.checkout_options 111 else: 112 command += self.export_options 113 command += self.extra_options 114 115 if self.branch: 116 command += ['-r', self.branch] 117 if self.revision: 118 command += ['-D', self.revision] 119 command += [self.cvsmodule] 120 121 c = runprocess.RunProcess(self.builder, command, d, 122 sendRC=False, timeout=self.timeout, 123 maxTime=self.maxTime, logEnviron=self.logEnviron, 124 usePTY=False) 125 self.command = c 126 return c.start()
127
128 - def parseGotRevision(self):
129 # CVS does not have any kind of revision stamp to speak of. We return 130 # the current timestamp as a best-effort guess, but this depends upon 131 # the local system having a clock that is 132 # reasonably-well-synchronized with the repository. 133 return time.strftime("%Y-%m-%d %H:%M:%S +0000", time.gmtime())
134