1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16  import os 
 17   
 18  from buildslave.commands.base import SourceBaseCommand 
 19  from buildslave import runprocess 
 20   
 21   
 22 -class Darcs(SourceBaseCommand): 
  23      """Darcs-specific VC operation. In addition to the arguments 
 24      handled by SourceBaseCommand, this command reads the following keys: 
 25   
 26      ['repourl'] (required): the Darcs repository string 
 27      """ 
 28   
 29      header = "darcs operation" 
 30   
 36   
 43   
 45          darcs = self.getCommand('darcs') 
 46          assert not self.revision 
 47           
 48          d = os.path.join(self.builder.basedir, self.srcdir) 
 49          command = [darcs, 'pull', '--all', '--verbose'] 
 50          c = runprocess.RunProcess(self.builder, command, d, 
 51                           sendRC=False, timeout=self.timeout, 
 52                           maxTime=self.maxTime, logEnviron=self.logEnviron, 
 53                           usePTY=False) 
 54          self.command = c 
 55          return c.start() 
  56   
 58          darcs = self.getCommand('darcs') 
 59           
 60          d = self.builder.basedir 
 61          command = [darcs, 'get', '--verbose', '--partial', 
 62                     '--repo-name', self.srcdir] 
 63          if self.revision: 
 64               
 65              n = os.path.join(self.builder.basedir, ".darcs-context") 
 66              f = open(n, "wb") 
 67              f.write(self.revision) 
 68              f.close() 
 69               
 70              command.append('--context') 
 71              command.append(n) 
 72          command.append(self.repourl) 
 73   
 74          c = runprocess.RunProcess(self.builder, command, d, 
 75                           sendRC=False, timeout=self.timeout, 
 76                           maxTime=self.maxTime, logEnviron=self.logEnviron, 
 77                           usePTY=False) 
 78          self.command = c 
 79          d = c.start() 
 80          if self.revision: 
 81              d.addCallback(self.removeContextFile, n) 
 82          return d 
  83   
 84 -    def removeContextFile(self, res, n): 
  85          os.unlink(n) 
 86          return res 
  87   
 89          darcs = self.getCommand('darcs') 
 90   
 91           
 92          command = [darcs, "changes", "--context"] 
 93          c = runprocess.RunProcess(self.builder, command, 
 94                           os.path.join(self.builder.basedir, self.srcdir), 
 95                           environ=self.env, timeout=self.timeout, 
 96                           sendStdout=False, sendStderr=False, sendRC=False, 
 97                           keepStdout=True, logEnviron=self.logEnviron, 
 98                           usePTY=False) 
 99          d = c.start() 
100          d.addCallback(lambda res: c.stdout) 
101          return d 
  102