Changeset 326 for perforceplugin/0.9
- Timestamp:
- 01/12/06 15:26:42 (3 years ago)
- Files:
-
- perforceplugin/0.9/p4trac/p4trac.py (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
perforceplugin/0.9/p4trac/p4trac.py
r215 r326 100 100 self.__class__.p4init = 0 101 101 102 try:103 102 # cache the first few changes 104 self. history = []103 self.__class__.history = [] 105 104 changes = self.__class__.p4c.run("changes", "-m", "10", "-s", "submitted") 106 105 for change in changes: 107 self.history.append(change['change']) 108 109 except self.__class__.p4c.P4Error: 110 for e in p4.errors: 111 self.log.debug(e) 112 self.__class__.p4init = 0 106 self.__class__.history.append(change['change']) 107 108 109 def _complete_history(self, rev): 110 if int(rev) > int(self.__class__.history[-1]): 111 _strRev = "@" + rev 112 _count = int(rev) - int(self.__class__.history[0]) 113 _idx = 0 114 else: 115 _strRev = "@<" + self.__class__.history[-1] 116 _count = int(self.__class__.history[-1]) - int(rev) + 1 117 _idx = len(self.__class__.history) 118 119 changes = self.__class__.p4c.run("changes", "-m", str(_count), "-s", "submitted", _strRev) 120 #self.log.debug("*** _complete history %s %s %s %s" % (rev, _count, _idx, changes)) 121 for change in changes: 122 num = change['change'] 123 #self.log.debug("*** _complete history add %d %s" % (_idx, num)) 124 self.__class__.history.insert(_idx, num) 125 _idx += 1 113 126 114 127 … … 124 137 Generate Changeset belonging to the given time period (start, stop). 125 138 """ 139 #_deb = time.time() 126 140 changes = self.__class__.p4c.run("changes", "-m", "100", "-t", "-s", "submitted") 127 141 #self.log.debug("*** get_changesets start = %s stop = %s %s" % (start, stop, changes)) … … 129 143 #self.log.debug("*** get_changesets %s" % (chgset)) 130 144 if float(chgset['time']) < start: 131 #self.log.debug("*** get_changesets end start %s %s" % (chgset['time'], start))145 #self.log.debug("*** get_changesets (%f) start = %s stop = %s " % (time.time() - _deb, start, stop)) 132 146 return 133 147 if float(chgset['time']) < stop: 134 148 #self.log.debug("*** get_changesets add start %s %s" % (chgset['time'], stop)) 135 149 yield PerforceChangeset(self.__class__.p4c, chgset['change'], chgset, self.log) 136 137 150 138 151 … … 208 221 #self.log.debug("*** get_youngest_rev rev = %s" % (rev)) 209 222 210 if rev != self.history[0]: 211 count = int(rev) - int(self.history[0]) 212 changes = self.__class__.p4c.run("changes", "-m", str(count), "-s", "submitted") 213 idx = 0 214 for change in changes: 215 num = change['change'] 216 if rev != num: 217 #self.log.debug("*** inserting change %s into history at %d" % (num, idx)) 218 self.history.insert(idx, num) 219 idx += 1 220 else: 221 break 223 if rev != self.__class__.history[0]: 224 self._complete_history(rev) 225 222 226 return rev 223 227 … … 227 231 Return the revision immediately preceding the specified revision. 228 232 """ 229 #self.log.debug("*** previous_rev rev = %s" % (rev)) 230 idx = self.history.index(rev) 231 if idx + 1 < len(self.history): 232 return self.history[idx + 1] 233 #self.log.debug("*** previous_rev rev = %s %s" % (rev, self.__class__.history)) 234 try: 235 idx = self.__class__.history.index(rev) 236 #self.log.debug("*** previous_rev rev = %s %s %s" % (rev, idx, self.__class__.history)) 237 if idx + 1 < len(self.__class__.history): 238 return self.__class__.history[idx + 1] 239 #self.log.debug("*** previous_rev2 rev = %s %s" % (rev, self.__class__.history)) 240 except ValueError: 241 #self.log.debug("*** previous_rev3 rev = %s %s" % (rev, self.__class__.history)) 242 None 243 244 self._complete_history(rev) 245 #self.log.debug("*** previous_rev4 rev = %s %s" % (rev, self.__class__.history)) 246 idx = self.__class__.history.index(rev) 247 if idx + 1 < len(self.__class__.history): 248 return self.__class__.history[idx + 1] 233 249 return None 234 250 … … 239 255 """ 240 256 #self.log.debug("*** next_rev rev = %s" % (rev)) 241 idx = self. history.index(rev)257 idx = self.__class__.history.index(rev) 242 258 if idx > 0: 243 return self. history[idx - 1]259 return self.__class__.history[idx - 1] 244 260 return None 245 261 … … 408 424 rev = logs[idx]['change'][index] 409 425 action = logs[idx]['action'][index] 410 if index < len(logs[idx]['how']):426 if logs[idx].has_key('how') and index < len(logs[idx]['how']): 411 427 how = logs[idx]['how'][index] 412 428 if how != None: … … 485 501 486 502 def __init__(self, p4c, rev, change, log): 503 #_deb = time.time() 487 504 self.log = log 488 505 self.rev = rev … … 498 515 date = int(self.change['time']) 499 516 Changeset.__init__(self, rev, message, author, date) 517 #self.log.debug("*** PerforceChangeset __init__ (%f)" % (time.time() - _deb)) 500 518 501 519 def get_changes(self): … … 506 524 Changeset.MOVE, and kind is one of Node.FILE or Node.DIRECTORY. 507 525 """ 526 #_deb = time.time() 508 527 #self.log.debug("*** get_changes = %s" % (self.change)) 509 528 files = self.change['depotFile'] … … 549 568 del changes[i - offset] 550 569 offset += 1 570 571 #self.log.debug("*** PerforceChangeset get_changes (%f)" % (time.time() - _deb)) 551 572 552 573 for c in changes:
