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

Source Code for Module buildslave.commands.darcs

 1  import os 
 2   
 3  from buildslave.commands.base import SourceBaseCommand 
 4  from buildslave import runprocess 
 5  from buildslave.commands import utils 
 6   
 7   
8 -class Darcs(SourceBaseCommand):
9 """Darcs-specific VC operation. In addition to the arguments 10 handled by SourceBaseCommand, this command reads the following keys: 11 12 ['repourl'] (required): the Darcs repository string 13 """ 14 15 header = "darcs operation" 16
17 - def setup(self, args):
18 SourceBaseCommand.setup(self, args) 19 self.repourl = args['repourl'] 20 self.sourcedata = "%s\n" % self.repourl 21 self.revision = self.args.get('revision')
22
23 - def sourcedirIsUpdateable(self):
24 # checking out a specific revision requires a full 'darcs get' 25 return (not self.revision and 26 not self.sourcedirIsPatched() and 27 os.path.isdir(os.path.join(self.builder.basedir, 28 self.srcdir, "_darcs")))
29
30 - def doVCUpdate(self):
31 darcs = self.getCommand('darcs') 32 assert not self.revision 33 # update: possible for mode in ('copy', 'update') 34 d = os.path.join(self.builder.basedir, self.srcdir) 35 command = [darcs, 'pull', '--all', '--verbose'] 36 c = runprocess.RunProcess(self.builder, command, d, 37 sendRC=False, timeout=self.timeout, 38 maxTime=self.maxTime, usePTY=False) 39 self.command = c 40 return c.start()
41
42 - def doVCFull(self):
43 darcs = self.getCommand('darcs') 44 # checkout or export 45 d = self.builder.basedir 46 command = [darcs, 'get', '--verbose', '--partial', 47 '--repo-name', self.srcdir] 48 if self.revision: 49 # write the context to a file 50 n = os.path.join(self.builder.basedir, ".darcs-context") 51 f = open(n, "wb") 52 f.write(self.revision) 53 f.close() 54 # tell Darcs to use that context 55 command.append('--context') 56 command.append(n) 57 command.append(self.repourl) 58 59 c = runprocess.RunProcess(self.builder, command, d, 60 sendRC=False, timeout=self.timeout, 61 maxTime=self.maxTime, usePTY=False) 62 self.command = c 63 d = c.start() 64 if self.revision: 65 d.addCallback(self.removeContextFile, n) 66 return d
67
68 - def removeContextFile(self, res, n):
69 os.unlink(n) 70 return res
71
72 - def parseGotRevision(self):
73 darcs = self.getCommand('darcs') 74 75 # we use 'darcs context' to find out what we wound up with 76 command = [darcs, "changes", "--context"] 77 c = runprocess.RunProcess(self.builder, command, 78 os.path.join(self.builder.basedir, self.srcdir), 79 environ=self.env, timeout=self.timeout, 80 sendStdout=False, sendStderr=False, sendRC=False, 81 keepStdout=True, usePTY=False) 82 d = c.start() 83 d.addCallback(lambda res: c.stdout) 84 return d
85