bug 445470 - pushlog contains 'None' at the end of the file causing HgPoller to barf
authorTed Mielczarek <ted.mielczarek@gmail.com>
Wed, 16 Jul 2008 08:00:00 -0400
changeset 29 d4bf9acf19591888bd670000ee1424ff374d116f
parent 28 646e1437fccf28939ed4bb414762953d542e451b
child 30 141f44a7f8be15b1cf5922dd827beccbff0cc6ed
push id7
push usertmielczarek@mozilla.com
push dateWed, 16 Jul 2008 12:00:09 +0000
bugs445470
bug 445470 - pushlog contains 'None' at the end of the file causing HgPoller to barf
pushlog-feed.py
--- a/pushlog-feed.py
+++ b/pushlog-feed.py
@@ -1,8 +1,9 @@
+import mercurial.hgweb.protocol as hgwebprotocol
 import mercurial.hgweb.webcommands as hgwebcommands
 from mercurial.templatefilters import xmlescape
 from mercurial.hgweb.common import HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR, paritygen
 from mercurial.node import short, bin, hex
 from mercurial import demandimport
 
 import sys, os.path, re
 from datetime import datetime
@@ -13,16 +14,20 @@ demandimport.disable()
 try:
     import sqlite3 as sqlite
 except ImportError:
     from pysqlite2 import dbapi2 as sqlite
 demandimport.enable()
 
 PUSHES_PER_PAGE = 10
 
+def addcommand(f, name):
+    setattr(hgwebprotocol, name, f)
+    hgwebprotocol.__all__.append(name)
+
 def addwebcommand(f, name):
     setattr(hgwebcommands, name, f)
     hgwebcommands.__all__.append(name)
 
 ATOM_MIMETYPE = 'application/atom+xml'
 
 def getpushlogentries(conn, start, count):
     """Get entries from the push log. Select |count| pushes starting at offset
@@ -63,17 +68,17 @@ def pushlogSetup(web, req):
         proto = 'http'
         default_port = "80"
     port = req.env["SERVER_PORT"]
     port = port != default_port and (":" + port) or ""
 
     urlbase = '%s://%s%s' % (proto, req.env['SERVER_NAME'], port)
     return (e, urlbase, reponame, total, start)
     
-def pushlogFeed(web, req, tmpl):
+def pushlogFeed(web, req):
     (e, urlbase, reponame, total, page) = pushlogSetup(web, req)
 
     resp = ["""<?xml version="1.0" encoding="UTF-8"?>
 <feed xmlns="http://www.w3.org/2005/Atom">
  <id>%(urlbase)s%(url)spushlog</id>
  <link rel="self" href="%(urlbase)s%(url)spushlog" />
  <updated>%(date)s</updated>
  <title>%(reponame)s Pushlog</title>""" % {'urlbase': urlbase,
@@ -182,12 +187,12 @@ def pushlogHTML(web, req, tmpl):
     return tmpl('pushlog',
                 changenav=changenav(),
                 rev=0,
                 entries=lambda **x: changelist(limit=0,**x),
                 latestentry=lambda **x: changelist(limit=1,**x),
                 archives=web.archivelist("tip"))
 
 
-addwebcommand(pushlogFeed, 'pushlog')
+addcommand(pushlogFeed, 'pushlog')
 addwebcommand(pushlogHTML, 'pushloghtml')
 
 cmdtable = {}