pushlog: alias repo as local variable (
bug 1286426); r=glandium
We're going to change behavior in an upcoming commit.
MozReview-Commit-ID: 89NJ82erTAN
--- a/hgext/pushlog-legacy/pushlog-feed.py
+++ b/hgext/pushlog-legacy/pushlog-feed.py
@@ -73,16 +73,17 @@ class PushlogQuery(object):
self.formatversion = 1
# ID of the last known push in the database.
self.lastpushid = None
def DoQuery(self):
"""Figure out what the query parameters are, and query the database
using those parameters."""
+ repo = self.repo
self.entries = []
if not self.conn:
# we didn't get a connection to the database, return empty
return
if self.querystart == QueryType.COUNT and not self.userquery and not self.changesetquery:
# Get entries from self.page, using self.querystart_value as
# the number of pushes per page.
try:
@@ -106,27 +107,27 @@ class PushlogQuery(object):
basequery = "SELECT id, user, date, node from pushlog LEFT JOIN changesets ON id = pushid WHERE "
where = []
params = {}
if self.querystart == QueryType.DATE:
where.append("date > :start_date")
params['start_date'] = self.querystart_value
elif self.querystart == QueryType.CHANGESET:
where.append("id > (select c.pushid from changesets c where c.node = :start_node)")
- params['start_node'] = hex(self.repo.lookup(self.querystart_value))
+ params['start_node'] = hex(repo.lookup(self.querystart_value))
elif self.querystart == QueryType.PUSHID:
where.append("id > :start_id")
params['start_id'] = self.querystart_value
if self.queryend == QueryType.DATE:
where.append("date < :end_date ")
params['end_date'] = self.queryend_value
elif self.queryend == QueryType.CHANGESET:
where.append("id <= (select c.pushid from changesets c where c.node = :end_node)")
- params['end_node'] = hex(self.repo.lookup(self.queryend_value))
+ params['end_node'] = hex(repo.lookup(self.queryend_value))
elif self.queryend == QueryType.PUSHID:
where.append("id <= :end_id ")
params['end_id'] = self.queryend_value
if self.userquery:
i = 0
subquery = []
for u in self.userquery:
@@ -135,17 +136,17 @@ class PushlogQuery(object):
i += 1
where.append('(' + ' OR '.join(subquery) + ')')
if self.changesetquery:
i = 0
subquery = []
for c in self.changesetquery:
subquery.append("id = (select c.pushid from changesets c where c.node = :node%s)" % i)
- params['node%d' % i] = hex(self.repo.lookup(c))
+ params['node%d' % i] = hex(repo.lookup(c))
i += 1
where.append('(' + ' OR '.join(subquery) + ')')
query = basequery + ' AND '.join(where) + ' ORDER BY id DESC, rev DESC'
#print "query: %s" % query
#print "params: %s" % params
try:
res = self.conn.execute(query, params)