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

Source Code for Module buildslave.commands.cvs

  1  import os 
  2  import time 
  3   
  4  from buildslave.commands.base import SourceBaseCommand 
  5  from buildslave import runprocess 
  6  from buildslave.commands import utils 
  7   
8 -class CVS(SourceBaseCommand):
9 """CVS-specific VC operation. In addition to the arguments handled by 10 SourceBaseCommand, this command reads the following keys: 11 12 ['cvsroot'] (required): the CVSROOT repository string 13 ['cvsmodule'] (required): the module to be retrieved 14 ['branch']: a '-r' tag or branch name to use for the checkout/update 15 ['login']: a string for use as a password to 'cvs login' 16 ['global_options']: a list of strings to use before the CVS verb 17 ['checkout_options']: a list of strings to use after checkout, 18 but before revision and branch specifiers 19 ['checkout_options']: a list of strings to use after export, 20 but before revision and branch specifiers 21 ['extra_options']: a list of strings to use after export and checkout, 22 but before revision and branch specifiers 23 """ 24 25 header = "cvs operation" 26
27 - def setup(self, args):
28 SourceBaseCommand.setup(self, args) 29 self.cvsroot = args['cvsroot'] 30 self.cvsmodule = args['cvsmodule'] 31 self.global_options = args.get('global_options', []) 32 self.checkout_options = args.get('checkout_options', []) 33 self.export_options = args.get('export_options', []) 34 self.extra_options = args.get('extra_options', []) 35 self.branch = args.get('branch') 36 self.login = args.get('login') 37 self.sourcedata = "%s\n%s\n%s\n" % (self.cvsroot, self.cvsmodule, 38 self.branch)
39
40 - def sourcedirIsUpdateable(self):
41 return (not self.sourcedirIsPatched() and 42 os.path.isdir(os.path.join(self.builder.basedir, 43 self.srcdir, "CVS")))
44
45 - def start(self):
46 cvs = self.getCommand("cvs") 47 if self.login is not None: 48 # need to do a 'cvs login' command first 49 d = self.builder.basedir 50 command = ([cvs, '-d', self.cvsroot] + self.global_options 51 + ['login']) 52 c = runprocess.RunProcess(self.builder, command, d, 53 sendRC=False, timeout=self.timeout, 54 maxTime=self.maxTime, 55 initialStdin=self.login+"\n", usePTY=False) 56 self.command = c 57 d = c.start() 58 d.addCallback(self._abandonOnFailure) 59 d.addCallback(self._didLogin) 60 return d 61 else: 62 return self._didLogin(None)
63
64 - def _didLogin(self, res):
65 # now we really start 66 return SourceBaseCommand.start(self)
67
68 - def doVCUpdate(self):
69 cvs = self.getCommand("cvs") 70 d = os.path.join(self.builder.basedir, self.srcdir) 71 command = [cvs, '-z3'] + self.global_options + ['update', '-dP'] 72 if self.branch: 73 command += ['-r', self.branch] 74 if self.revision: 75 command += ['-D', self.revision] 76 c = runprocess.RunProcess(self.builder, command, d, 77 sendRC=False, timeout=self.timeout, 78 maxTime=self.maxTime, usePTY=False) 79 self.command = c 80 return c.start()
81
82 - def doVCFull(self):
83 cvs = self.getCommand("cvs") 84 d = self.builder.basedir 85 if self.mode == "export": 86 verb = "export" 87 else: 88 verb = "checkout" 89 command = ([cvs, '-d', self.cvsroot, '-z3'] + 90 self.global_options + 91 [verb, '-d', self.srcdir]) 92 93 if verb == "checkout": 94 command += self.checkout_options 95 else: 96 command += self.export_options 97 command += self.extra_options 98 99 if self.branch: 100 command += ['-r', self.branch] 101 if self.revision: 102 command += ['-D', self.revision] 103 command += [self.cvsmodule] 104 105 c = runprocess.RunProcess(self.builder, command, d, 106 sendRC=False, timeout=self.timeout, 107 maxTime=self.maxTime, usePTY=False) 108 self.command = c 109 return c.start()
110
111 - def parseGotRevision(self):
112 # CVS does not have any kind of revision stamp to speak of. We return 113 # the current timestamp as a best-effort guess, but this depends upon 114 # the local system having a clock that is 115 # reasonably-well-synchronized with the repository. 116 return time.strftime("%Y-%m-%d %H:%M:%S +0000", time.gmtime())
117