1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 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   
 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   
 58   
 60          cvs = self.getCommand("cvs") 
 61          if self.login is not None: 
 62               
 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   
 82   
 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   
 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   
129           
130           
131           
132           
133          return time.strftime("%Y-%m-%d %H:%M:%S +0000", time.gmtime()) 
  134