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

Source Code for Module buildslave.commands.darcs

  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   
 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
31 - def setup(self, args):
32 SourceBaseCommand.setup(self, args) 33 self.repourl = args['repourl'] 34 self.sourcedata = "%s\n" % self.repourl 35 self.revision = self.args.get('revision')
36
37 - def sourcedirIsUpdateable(self):
38 # checking out a specific revision requires a full 'darcs get' 39 return (not self.revision and 40 not self.sourcedirIsPatched() and 41 os.path.isdir(os.path.join(self.builder.basedir, 42 self.srcdir, "_darcs")))
43
44 - def doVCUpdate(self):
45 darcs = self.getCommand('darcs') 46 assert not self.revision 47 # update: possible for mode in ('copy', 'update') 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
57 - def doVCFull(self):
58 darcs = self.getCommand('darcs') 59 # checkout or export 60 d = self.builder.basedir 61 command = [darcs, 'get', '--verbose', '--lazy', 62 '--repo-name', self.srcdir] 63 if self.revision: 64 # write the context to a file 65 n = os.path.join(self.builder.basedir, ".darcs-context") 66 f = open(n, "wb") 67 f.write(self.revision) 68 f.close() 69 # tell Darcs to use that context 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
88 - def parseGotRevision(self):
89 darcs = self.getCommand('darcs') 90 91 # we use 'darcs context' to find out what we wound up with 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