Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix for issue #127. The "got_revision" property in perforce is now se…

…t after a P4 source

step. This fix consists of the patch in issue #229 (with cleanup) and adjustments to
the p4 tests (test_vc.py). p4 tests now support newer versions of p4d and check the
"got_revision" value via (has_got_revision = True)
  • Loading branch information...
commit ab61561c9bc98d69b64db2b3bdb5c05dce969264 1 parent a3c7af3
gollum authored
Showing with 59 additions and 14 deletions.
  1. +51 −12 buildbot/slave/commands.py
  2. +8 −2 buildbot/test/test_vc.py
View
63 buildbot/slave/commands.py
@@ -2319,24 +2319,67 @@ def _parse(res):
registerSlaveCommand("hg", Mercurial, command_version)
-class P4(SourceBase):
- """A P4 source-updater.
+class P4Base(SourceBase):
+ """Base class for P4 source-updaters
['p4port'] (required): host:port for server to access
['p4user'] (optional): user to use for access
['p4passwd'] (optional): passwd to try for the user
['p4client'] (optional): client spec to use
- ['p4extra_views'] (optional): additional client views to use
"""
-
- header = "p4"
-
def setup(self, args):
SourceBase.setup(self, args)
self.p4port = args['p4port']
self.p4client = args['p4client']
self.p4user = args['p4user']
self.p4passwd = args['p4passwd']
+
+ def parseGotRevision(self):
+ # Executes a p4 command that will give us the latest changelist number
+ # of any file under the current (or default) client:
+ command = ['p4']
+ if self.p4port:
+ command.extend(['-p', self.p4port])
+ if self.p4user:
+ command.extend(['-u', self.p4user])
+ if self.p4passwd:
+ command.extend(['-P', self.p4passwd])
+ if self.p4client:
+ command.extend(['-c', self.p4client])
+ command.extend(['changes', '-m', '1', '#have'])
+ c = ShellCommand(self.builder, command, self.builder.basedir,
+ environ=self.env, timeout=self.timeout,
+ sendStdout=True, sendStderr=False, sendRC=False,
+ keepStdout=True)
+ self.command = c
+ d = c.start()
+
+ def _parse(res):
+ # 'p4 -c clien-name change -m 1 "#have"' will produce an output like:
+ # "Change 28147 on 2008/04/07 by p4user@hostname..."
+ # The number after "Change" is the one we want.
+ m = re.match('Change\s+(\d+)\s+', c.stdout)
+ if m:
+ return m.group(1)
+ return None
+ d.addCallback(_parse)
+ return d
+
+
+class P4(P4Base):
+ """A P4 source-updater.
+
+ ['p4port'] (required): host:port for server to access
+ ['p4user'] (optional): user to use for access
+ ['p4passwd'] (optional): passwd to try for the user
+ ['p4client'] (optional): client spec to use
+ ['p4extra_views'] (optional): additional client views to use
+ """
+
+ header = "p4"
+
+ def setup(self, args):
+ P4Base.setup(self, args)
self.p4base = args['p4base']
self.p4extra_views = args['p4extra_views']
self.p4mode = args['mode']
@@ -2440,7 +2483,7 @@ def doVCFull(self):
registerSlaveCommand("p4", P4, command_version)
-class P4Sync(SourceBase):
+class P4Sync(P4Base):
"""A partial P4 source-updater. Requires manual setup of a per-slave P4
environment. The only thing which comes from the master is P4PORT.
'mode' is required to be 'copy'.
@@ -2454,12 +2497,8 @@ class P4Sync(SourceBase):
header = "p4 sync"
def setup(self, args):
- SourceBase.setup(self, args)
+ P4Base.setup(self, args)
self.vcexe = getCommand("p4")
- self.p4port = args['p4port']
- self.p4user = args['p4user']
- self.p4passwd = args['p4passwd']
- self.p4client = args['p4client']
def sourcedirIsUpdateable(self):
return True
View
10 buildbot/test/test_vc.py
@@ -1384,7 +1384,12 @@ def __init__(self):
def outReceived(self, data):
# When it says starting, it has bound to the socket.
if self.started:
- if data.startswith('Perforce Server starting...'):
+ #
+ # Make sure p4d has started. Newer versions of p4d
+ # have more verbose messaging when db files don't exist, so
+ # we use re.search instead of startswith.
+ #
+ if re.search('Perforce Server starting...', data):
self.started.callback(None)
else:
print "p4d said %r" % data
@@ -1492,7 +1497,8 @@ class P4(VCBase, unittest.TestCase):
metadir = None
vctype = "source.P4"
vc_name = "p4"
-
+ has_got_revision = True
+
def tearDownClass(self):
if self.helper:
return self.helper.shutdown_p4d()
Please sign in to comment.
Something went wrong with that request. Please try again.