Ticket #2: bzrpoller-working.patch
| File bzrpoller-working.patch, 2.4 kB (added by ijon, 10 months ago) |
|---|
-
bzrpoller.py
old new 15 15 implements(interfaces.IChangeSource) 16 16 17 17 compare_attrs = ["location", "pollinterval"] 18 18 19 19 20 20 parent = None # filled in when we're added 21 last_ change= None21 last_revno = None 22 22 loop = None 23 23 working = False 24 24 … … 50 50 def poll(self): 51 51 log.msg("BzrPoller polling") 52 52 # location="http://bazaar-vcs.org/bzr/bzr.dev" 53 b = Branch.open_containing(self. url)[0]53 b = Branch.open_containing(self.location)[0] 54 54 # this is subclass of bzrlib.branch.Branch 55 current_revision = b.revno() 55 current_revno = b.revno() 56 if self.last_revno is None: 57 self.last_revno = current_revno 58 log.msg('BzrPoller: starting at %s' % (self.last_revno)) 59 return 60 if current_revno == self.last_revno: 61 log.msg('BzrPoller: no new revisions since %s' % (self.last_revno)) 62 return 56 63 # NOTE: b.revision_history() does network IO, and is blocking. 57 revisions = b.revision_history()[ last_revno:] # each is an id string64 revisions = b.revision_history()[self.last_revno:current_revno] # each is an id string 58 65 changes = [] 59 for r in revisions: 66 # any way in bzrlib to get revno from revision_id? 67 # revnos in a branch are sequential, without gaps 68 for r, revno in zip(revisions, xrange(self.last_revno+1, current_revno+1)): 60 69 rev = b.repository.get_revision(r) 61 # bzrlib.revision.Revision62 70 who = rev.committer 63 71 comments = rev.message 64 72 when = rev.timestamp … … 72 80 [f[0] for f in d.modified] 73 81 ) 74 82 75 # revision= ?76 83 # branch= ? 77 c = Change(who= rev.committer,84 c = Change(who=who, 78 85 files=files, 79 comments=rev.message, 80 when=rev.timestamp, 86 comments=comments, 87 revision=revno, 88 when=when, 81 89 ) 82 90 changes.append(c) 83 91 for c in changes: 84 92 self.parent.addChange(c) 93 self.last_revno = current_revno 85 94 log.msg("BzrPoller finished polling, %d changes found" % len(changes))
![[Buildbot Logo]](/trac/chrome/site/header-text-transparent.png)