[Buildbot-commits] [Buildbot] #2061: patch: make P4Poller pick up where it left off

Buildbot nobody at buildbot.net
Fri Jul 22 17:40:59 UTC 2011


#2061: patch: make P4Poller pick up where it left off
------------------------+-----------------------
Reporter:  dberger      |      Owner:
    Type:  enhancement  |     Status:  new
Priority:  major        |  Milestone:  undecided
 Version:  0.8.4p2      |   Keywords:
------------------------+-----------------------
 {{{
 $ p4 diff -du ../external/buildbot-0.8.4p1/...
 --- //main/tools/external/buildbot-0.8.4p1/buildbot/changes/p4poller.py
 2011-06-28 16:38:20.000000000 -0700
 +++
 /home/buildbot/buildbot/external/buildbot-0.8.4p1/buildbot/changes/p4poller.py
 2011-06-28 16:38:20.000000000 -0700
 @@ -44,8 +44,10 @@
      """This source will poll a perforce repository for changes and submit
      them to the change master."""

      compare_attrs = ["p4port", "p4user", "p4passwd", "p4base",
 -                     "p4bin", "pollInterval"]
 +                     "p4bin", "pollInterval",
 +                     "split_file"]

      env_vars = ["P4CLIENT", "P4PORT", "P4PASSWD", "P4USER",
                  "P4CHARSET"]
 @@ -92,6 +94,35 @@

      @defer.deferredGenerator
      def _poll(self):
 +        if self.last_change is None:
 +            # try asking the master for it's most recent processed
 +            # change, turn that into a p4 change number, and start
 +            # there
 +            try:
 +                log.msg('P4Poller: asking buildmaster for latest
 changeid')
 +                wfd = defer.waitForDeferred(
 +                    self.master.db.changes.getLatestChangeid() )
 +                yield wfd
 +                latest_change_id =  wfd.getResult()
 +                log.msg('P4Poller: asking buildmaster about changeid =
 %s' % str(latest_change_id) )
 +                wfd = defer.waitForDeferred(
 +                    self.master.db.changes.getChange( latest_change_id )
 )
 +                yield wfd
 +                chDict = wfd.getResult()
 +                revision = int( chDict.get( 'revision', -1 ) )
 +                when_timestamp = int( chDict.get( 'when_timestamp', 0 ) )
 +                now = time.time()
 +                log.msg('P4Poller: last saw revision %d on %s' % (
 revision,
 +
 time.ctime( when_timestamp ) ) )
 +                if now - when_timestamp < 0 or now - when_timestamp >
 60*24:
 +                    log.msg('P4Poller: last seen revision was in the
 future, or more than a day ago, ignoring')
 +                else:
 +                    self.last_change = int( chDict.get( 'revision', None
 ) )
 +
 +            except Exception, e:
 +                print "couldn't determine last change, starting with the
 next one: ", e
 +
          args = []
          if self.p4port:
              args.extend(['-p', self.p4port])
 @@ -124,6 +155,16 @@
                  log.msg('P4Poller: starting at change %d' % num)
                  self.last_change = num
                  return
 +
 +            if ( num - last_change ) < 0 or ( num - last_change ) >
 10000:
 +                # if we suddenly go negative, or we've seen a crazy
 number
 +                # of changes, start on the change we just saw
 +                log.msg('P4Poller: saw a ridiculous number of changes,
 starting at change %d' % num)
 +                self.last_change = num
 +                return
 +
              changelists.append(num)
          changelists.reverse() # oldest first
 }}}

-- 
Ticket URL: <http://trac.buildbot.net/ticket/2061>
Buildbot <http://buildbot.net/>
Buildbot: build/test automation


More information about the Commits mailing list