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
22
29
31 darcs = self.getCommand('darcs')
32 assert not self.revision
33
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
43 darcs = self.getCommand('darcs')
44
45 d = self.builder.basedir
46 command = [darcs, 'get', '--verbose', '--partial',
47 '--repo-name', self.srcdir]
48 if self.revision:
49
50 n = os.path.join(self.builder.basedir, ".darcs-context")
51 f = open(n, "wb")
52 f.write(self.revision)
53 f.close()
54
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
73 darcs = self.getCommand('darcs')
74
75
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