| 1 | --- /usr/lib/python2.3/site-packages/buildbot/slave/commands.py-orig 2008-04-08 17:00:59.000000000 -0700 |
|---|
| 2 | +++ /usr/lib/python2.3/site-packages/buildbot/slave/commands.py 2008-04-09 12:09:42.000000000 -0700 |
|---|
| 3 | @@ -2322,8 +2322,58 @@ |
|---|
| 4 | |
|---|
| 5 | registerSlaveCommand("hg", Mercurial, command_version) |
|---|
| 6 | |
|---|
| 7 | +class P4Base(SourceBase): |
|---|
| 8 | + """Base class for P4 source-updaters |
|---|
| 9 | |
|---|
| 10 | -class P4(SourceBase): |
|---|
| 11 | + ['p4port'] (required): host:port for server to access |
|---|
| 12 | + ['p4user'] (optional): user to use for access |
|---|
| 13 | + ['p4passwd'] (optional): passwd to try for the user |
|---|
| 14 | + ['p4client'] (optional): client spec to use |
|---|
| 15 | + """ |
|---|
| 16 | + def setup(self, args): |
|---|
| 17 | + SourceBase.setup(self, args) |
|---|
| 18 | + self.p4port = args['p4port'] |
|---|
| 19 | + self.p4client = args['p4client'] |
|---|
| 20 | + self.p4user = args['p4user'] |
|---|
| 21 | + self.p4passwd = args['p4passwd'] |
|---|
| 22 | + |
|---|
| 23 | + def parseGotRevision(self): |
|---|
| 24 | + # Executes a p4 command that will give us the latest changelist number |
|---|
| 25 | + # of any file under the current (or default) client: |
|---|
| 26 | + command = ['p4'] |
|---|
| 27 | + if self.p4port: |
|---|
| 28 | + command.extend(['-p', self.p4port]) |
|---|
| 29 | + if self.p4user: |
|---|
| 30 | + command.extend(['-u', self.p4user]) |
|---|
| 31 | + if self.p4passwd: |
|---|
| 32 | + command.extend(['-P', self.p4passwd]) |
|---|
| 33 | + if self.p4client: |
|---|
| 34 | + command.extend(['-c', self.p4client]) |
|---|
| 35 | + command.extend(['changes', '-m', '1', '#have']) |
|---|
| 36 | + c = ShellCommand(self.builder, command, self.builder.basedir, |
|---|
| 37 | + environ=self.env, timeout=self.timeout, |
|---|
| 38 | + sendStdout=True, sendStderr=False, sendRC=False, |
|---|
| 39 | + keepStdout=True) |
|---|
| 40 | + self.command = c |
|---|
| 41 | + d = c.start() |
|---|
| 42 | + |
|---|
| 43 | + def _parse(res): |
|---|
| 44 | + # 'p4 -c clien-name change -m 1 "#have"' will produce an output like: |
|---|
| 45 | + # "Change 28147 on 2008/04/07 by p4user@hostname..." |
|---|
| 46 | + # The number after "Change" is the one we want. |
|---|
| 47 | + got_version = None |
|---|
| 48 | + cmdResult = c.stdout.strip() |
|---|
| 49 | + import re |
|---|
| 50 | + changePattern = re.compile(r'Change +(\d+) ') |
|---|
| 51 | + found = changePattern.search(cmdResult).groups() |
|---|
| 52 | + got_version = found[0] |
|---|
| 53 | + return got_version |
|---|
| 54 | + |
|---|
| 55 | + d.addCallback(_parse) |
|---|
| 56 | + return d |
|---|
| 57 | + |
|---|
| 58 | + |
|---|
| 59 | +class P4(P4Base): |
|---|
| 60 | """A P4 source-updater. |
|---|
| 61 | |
|---|
| 62 | ['p4port'] (required): host:port for server to access |
|---|
| 63 | @@ -2336,11 +2386,7 @@ |
|---|
| 64 | header = "p4" |
|---|
| 65 | |
|---|
| 66 | def setup(self, args): |
|---|
| 67 | - SourceBase.setup(self, args) |
|---|
| 68 | - self.p4port = args['p4port'] |
|---|
| 69 | - self.p4client = args['p4client'] |
|---|
| 70 | - self.p4user = args['p4user'] |
|---|
| 71 | - self.p4passwd = args['p4passwd'] |
|---|
| 72 | + P4Base.setup(self, args) |
|---|
| 73 | self.p4base = args['p4base'] |
|---|
| 74 | self.p4extra_views = args['p4extra_views'] |
|---|
| 75 | self.p4mode = args['mode'] |
|---|
| 76 | @@ -2444,7 +2490,7 @@ |
|---|
| 77 | registerSlaveCommand("p4", P4, command_version) |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | -class P4Sync(SourceBase): |
|---|
| 81 | +class P4Sync(P4Base): |
|---|
| 82 | """A partial P4 source-updater. Requires manual setup of a per-slave P4 |
|---|
| 83 | environment. The only thing which comes from the master is P4PORT. |
|---|
| 84 | 'mode' is required to be 'copy'. |
|---|
| 85 | @@ -2458,12 +2504,8 @@ |
|---|
| 86 | header = "p4 sync" |
|---|
| 87 | |
|---|
| 88 | def setup(self, args): |
|---|
| 89 | - SourceBase.setup(self, args) |
|---|
| 90 | + P4Base.setup(self, args) |
|---|
| 91 | self.vcexe = getCommand("p4") |
|---|
| 92 | - self.p4port = args['p4port'] |
|---|
| 93 | - self.p4user = args['p4user'] |
|---|
| 94 | - self.p4passwd = args['p4passwd'] |
|---|
| 95 | - self.p4client = args['p4client'] |
|---|
| 96 | |
|---|
| 97 | def sourcedirIsUpdateable(self): |
|---|
| 98 | return True |
|---|