1 import os
2 import time
3
4 from buildslave.commands.base import SourceBaseCommand
5 from buildslave import runprocess
6 from buildslave.commands import utils
7
8 -class CVS(SourceBaseCommand):
9 """CVS-specific VC operation. In addition to the arguments handled by
10 SourceBaseCommand, this command reads the following keys:
11
12 ['cvsroot'] (required): the CVSROOT repository string
13 ['cvsmodule'] (required): the module to be retrieved
14 ['branch']: a '-r' tag or branch name to use for the checkout/update
15 ['login']: a string for use as a password to 'cvs login'
16 ['global_options']: a list of strings to use before the CVS verb
17 ['checkout_options']: a list of strings to use after checkout,
18 but before revision and branch specifiers
19 ['checkout_options']: a list of strings to use after export,
20 but before revision and branch specifiers
21 ['extra_options']: a list of strings to use after export and checkout,
22 but before revision and branch specifiers
23 """
24
25 header = "cvs operation"
26
28 SourceBaseCommand.setup(self, args)
29 self.cvsroot = args['cvsroot']
30 self.cvsmodule = args['cvsmodule']
31 self.global_options = args.get('global_options', [])
32 self.checkout_options = args.get('checkout_options', [])
33 self.export_options = args.get('export_options', [])
34 self.extra_options = args.get('extra_options', [])
35 self.branch = args.get('branch')
36 self.login = args.get('login')
37 self.sourcedata = "%s\n%s\n%s\n" % (self.cvsroot, self.cvsmodule,
38 self.branch)
39
44
63
67
69 cvs = self.getCommand("cvs")
70 d = os.path.join(self.builder.basedir, self.srcdir)
71 command = [cvs, '-z3'] + self.global_options + ['update', '-dP']
72 if self.branch:
73 command += ['-r', self.branch]
74 if self.revision:
75 command += ['-D', self.revision]
76 c = runprocess.RunProcess(self.builder, command, d,
77 sendRC=False, timeout=self.timeout,
78 maxTime=self.maxTime, usePTY=False)
79 self.command = c
80 return c.start()
81
83 cvs = self.getCommand("cvs")
84 d = self.builder.basedir
85 if self.mode == "export":
86 verb = "export"
87 else:
88 verb = "checkout"
89 command = ([cvs, '-d', self.cvsroot, '-z3'] +
90 self.global_options +
91 [verb, '-d', self.srcdir])
92
93 if verb == "checkout":
94 command += self.checkout_options
95 else:
96 command += self.export_options
97 command += self.extra_options
98
99 if self.branch:
100 command += ['-r', self.branch]
101 if self.revision:
102 command += ['-D', self.revision]
103 command += [self.cvsmodule]
104
105 c = runprocess.RunProcess(self.builder, command, d,
106 sendRC=False, timeout=self.timeout,
107 maxTime=self.maxTime, usePTY=False)
108 self.command = c
109 return c.start()
110
112
113
114
115
116 return time.strftime("%Y-%m-%d %H:%M:%S +0000", time.gmtime())
117