1 import os
2
3 from twisted.python import log
4
5 from buildslave.commands.base import SourceBaseCommand
6 from buildslave import runprocess
7 from buildslave.commands import utils
8
9
10 -class BK(SourceBaseCommand):
11 """BitKeeper-specific VC operation. In addition to the arguments
12 handled by SourceBaseCommand, this command reads the following keys:
13
14 ['bkurl'] (required): the BK repository string
15 """
16
17 header = "bk operation"
18
20 SourceBaseCommand.setup(self, args)
21 self.bkurl = args['bkurl']
22 self.sourcedata = '"%s\n"' % self.bkurl
23
24 self.bk_args = []
25 if args.get('extra_args', None) is not None:
26 self.bk_args.extend(args['extra_args'])
27
34
48
65
67 """
68 Get the (shell) command used to determine BK revision number
69 of checked-out code
70
71 return: list of strings, passable as the command argument to RunProcess
72 """
73 bk = self.getCommand('bk')
74 return [bk, "changes", "-r+", "-d:REV:"]
75
77 c = runprocess.RunProcess(self.builder,
78 self.getBKVersionCommand(),
79 os.path.join(self.builder.basedir, self.srcdir),
80 environ=self.env, timeout=self.timeout,
81 sendStdout=False, sendStderr=False, sendRC=False,
82 keepStdout=True, usePTY=False)
83 d = c.start()
84 def _parse(res):
85 r_raw = c.stdout.strip()
86 got_version = None
87 try:
88 r = r_raw
89 except:
90 msg = ("BK.parseGotRevision unable to parse output: (%s)" % r_raw)
91 log.msg(msg)
92 self.sendStatus({'header': msg + "\n"})
93 raise ValueError(msg)
94 return r
95 d.addCallback(_parse)
96 return d
97