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

Source Code for Module buildslave.commands.bk

 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
19 - def setup(self, args):
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
28 - def sourcedirIsUpdateable(self):
29 if os.path.exists(os.path.join(self.builder.basedir, 30 self.srcdir, ".buildbot-patched")): 31 return False 32 return os.path.isfile(os.path.join(self.builder.basedir, 33 self.srcdir, "BK/parent"))
34
35 - def doVCUpdate(self):
36 bk = self.getCommand('bk') 37 revision = self.args['revision'] or 'HEAD' 38 # update: possible for mode in ('copy', 'update') 39 d = os.path.join(self.builder.basedir, self.srcdir) 40 41 # Revision is ignored since the BK free client doesn't support it. 42 command = [bk, 'pull'] 43 c = runprocess.RunProcess(self.builder, command, d, 44 sendRC=False, timeout=self.timeout, 45 keepStdout=True, usePTY=False) 46 self.command = c 47 return c.start()
48
49 - def doVCFull(self):
50 bk = self.getCommand('bk') 51 52 revision_arg = '' 53 if self.args['revision']: 54 revision_arg = "-r%s" % self.args['revision'] 55 56 d = self.builder.basedir 57 58 command = [bk, 'clone', revision_arg] + self.bk_args + \ 59 [self.bkurl, self.srcdir] 60 c = runprocess.RunProcess(self.builder, command, d, 61 sendRC=False, timeout=self.timeout, 62 usePTY=False) 63 self.command = c 64 return c.start()
65
66 - def getBKVersionCommand(self):
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
76 - def parseGotRevision(self):
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