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, usePTY=False) 53 self.command = c 54 return c.start()
55
56 - def doVCFull(self):
57 darcs = self.getCommand('darcs') 58 # checkout or export 59 d = self.builder.basedir 60 command = [darcs, 'get', '--verbose', '--partial', 61 '--repo-name', self.srcdir] 62 if self.revision: 63 # write the context to a file 64 n = os.path.join(self.builder.basedir, ".darcs-context") 65 f = open(n, "wb") 66 f.write(self.revision) 67 f.close() 68 # tell Darcs to use that context 69 command.append('--context') 70 command.append(n) 71 command.append(self.repourl) 72 73 c = runprocess.RunProcess(self.builder, command, d, 74 sendRC=False, timeout=self.timeout, 75 maxTime=self.maxTime, usePTY=False) 76 self.command = c 77 d = c.start() 78 if self.revision: 79 d.addCallback(self.removeContextFile, n) 80 return d
81
82 - def removeContextFile(self, res, n):
83 os.unlink(n) 84 return res
85
86 - def parseGotRevision(self):
87 darcs = self.getCommand('darcs') 88 89 # we use 'darcs context' to find out what we wound up with 90 command = [darcs, "changes", "--context"] 91 c = runprocess.RunProcess(self.builder, command, 92 os.path.join(self.builder.basedir, self.srcdir), 93 environ=self.env, timeout=self.timeout, 94 sendStdout=False, sendStderr=False, sendRC=False, 95 keepStdout=True, usePTY=False) 96 d = c.start() 97 d.addCallback(lambda res: c.stdout) 98 return d
99