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", usePTY=False) 70 self.command = c 71 d = c.start() 72 d.addCallback(self._abandonOnFailure) 73 d.addCallback(self._didLogin) 74 return d 75 else: 76 return self._didLogin(None)
77
78 - def _didLogin(self, res):
79 # now we really start 80 return SourceBaseCommand.start(self)
81
82 - def doVCUpdate(self):
83 cvs = self.getCommand("cvs") 84 d = os.path.join(self.builder.basedir, self.srcdir) 85 command = [cvs, '-z3'] + self.global_options + ['update', '-dP'] 86 if self.branch: 87 command += ['-r', self.branch] 88 if self.revision: 89 command += ['-D', self.revision] 90 c = runprocess.RunProcess(self.builder, command, d, 91 sendRC=False, timeout=self.timeout, 92 maxTime=self.maxTime, usePTY=False) 93 self.command = c 94 return c.start()
95
96 - def doVCFull(self):
97 cvs = self.getCommand("cvs") 98 d = self.builder.basedir 99 if self.mode == "export": 100 verb = "export" 101 else: 102 verb = "checkout" 103 command = ([cvs, '-d', self.cvsroot, '-z3'] + 104 self.global_options + 105 [verb, '-d', self.srcdir]) 106 107 if verb == "checkout": 108 command += self.checkout_options 109 else: 110 command += self.export_options 111 command += self.extra_options 112 113 if self.branch: 114 command += ['-r', self.branch] 115 if self.revision: 116 command += ['-D', self.revision] 117 command += [self.cvsmodule] 118 119 c = runprocess.RunProcess(self.builder, command, d, 120 sendRC=False, timeout=self.timeout, 121 maxTime=self.maxTime, usePTY=False) 122 self.command = c 123 return c.start()
124
125 - def parseGotRevision(self):
126 # CVS does not have any kind of revision stamp to speak of. We return 127 # the current timestamp as a best-effort guess, but this depends upon 128 # the local system having a clock that is 129 # reasonably-well-synchronized with the repository. 130 return time.strftime("%Y-%m-%d %H:%M:%S +0000", time.gmtime())
131