| | 192 | |
| | 193 | class PerforceExtractor(SourceStampExtractor): |
| | 194 | patchlevel = 1 |
| | 195 | vcexe = "p4" |
| | 196 | def getBaseRevision(self): |
| | 197 | d = self.dovc(["changes", "-m1 ..."]) |
| | 198 | d.addCallback(self.parseStatus) |
| | 199 | return d |
| | 200 | |
| | 201 | def parseStatus(self, res): |
| | 202 | # |
| | 203 | # extract the base change number |
| | 204 | # |
| | 205 | m = re.search(r'Change (\d+)',res) |
| | 206 | if m: |
| | 207 | self.baserev = m.group(1) |
| | 208 | else: |
| | 209 | self.baserev = res # the whole context file |
| | 210 | |
| | 211 | def readPatch(self, res, patchlevel): |
| | 212 | # |
| | 213 | # extract the actual patch from "res" |
| | 214 | # |
| | 215 | mpatch = "" |
| | 216 | branch = "main" |
| | 217 | for line in res.split("\n"): |
| | 218 | m = re.search(r'==== //depot/([\w\_\-]+)/([\w\/\.\d\-\_]+)#(\d+) -',line) |
| | 219 | if m: |
| | 220 | mpatch += "--- /%s#%s\n" % (m.group(2), m.group(3) ) |
| | 221 | mpatch += "+++ /%s\n" % (m.group(2) ) |
| | 222 | branch = m.group(1) |
| | 223 | pass |
| | 224 | else: |
| | 225 | mpatch += line |
| | 226 | mpatch += "\n" |
| | 227 | self.branch = branch |
| | 228 | self.patch = (patchlevel, mpatch) |
| | 229 | def getPatch(self, res): |
| | 230 | d = self.dovc(["diff", "-du"]) |
| | 231 | d.addCallback(self.readPatch, self.patchlevel) |
| | 232 | return d |
| | 233 | |
| | 234 | |