pushlog: only import sqlite3; r=glandium
I'm pretty sure we needed the fallback when we were running an ancient
Python that didn't have sqlite3. We run Python 2.7 now and sqlite3
should always be available.
MozReview-Commit-ID: F3k8NfJZofO
--- a/hgext/pushlog-legacy/pushlog-feed.py
+++ b/hgext/pushlog-legacy/pushlog-feed.py
@@ -15,20 +15,17 @@ from datetime import datetime
import time
from math import ceil
sys.path.append(os.path.dirname(__file__))
demandimport.disable()
from parsedatetime import parsedatetime as pdt
-try:
- import sqlite3 as sqlite
-except ImportError:
- from pysqlite2 import dbapi2 as sqlite
+import sqlite3
demandimport.enable()
testedwith = '3.6 3.7'
cal = pdt.Calendar()
PUSHES_PER_PAGE = 10
def addcommand(f, name):
@@ -92,17 +89,17 @@ class PushlogQuery(object):
limit = ""
if self.tipsonly:
limit = " LIMIT 1"
res2 = self.conn.execute("SELECT node FROM changesets WHERE pushid = ? ORDER BY rev DESC" + limit, (id,))
for node, in res2:
self.entries.append((id,user,date,node))
# get count of pushes
self.totalentries = self.conn.execute("SELECT COUNT(*) FROM pushlog").fetchone()[0]
- except sqlite.OperationalError:
+ except sqlite3.OperationalError:
# likely just an empty db, so return an empty result
pass
else:
# for all other queries we'll build the query piece by piece
basequery = "SELECT id, user, date, node from pushlog LEFT JOIN changesets ON id = pushid WHERE "
where = []
params = {}
if self.querystart == QueryType.DATE:
@@ -153,26 +150,26 @@ class PushlogQuery(object):
# Empty push.
if not node:
continue
if self.tipsonly and id == lastid:
continue
self.entries.append((id,user,date,node))
lastid = id
- except sqlite.OperationalError:
+ except sqlite3.OperationalError:
# likely just an empty db, so return an empty result
pass
try:
query = 'select id from pushlog order by id desc limit 1'
row = self.conn.execute(query).fetchone()
if row:
self.lastpushid = row[0]
- except sqlite.OperationalError:
+ except sqlite3.OperationalError:
pass
def description(self):
if self.querystart == QueryType.COUNT and not self.userquery and not self.changesetquery:
return ''
bits = []
isotime = lambda x: datetime.fromtimestamp(x).isoformat(' ')
if self.querystart == QueryType.DATE:
@@ -236,18 +233,18 @@ def pushlogSetup(repo, req):
reponame = os.path.basename(repopath)
if reponame == '.hg':
reponame = os.path.basename(os.path.dirname(repopath))
pushdb = os.path.join(repo.path, "pushlog2.db")
# If the database doesn't already exist, don't try to open it.
conn = None
if os.path.isfile(pushdb):
try:
- conn = sqlite.connect(pushdb)
- except sqlite.OperationalError:
+ conn = sqlite3.connect(pushdb)
+ except sqlite3.OperationalError:
pass
if 'node' in req.form:
page = int(req.form['node'][0])
else:
page = 1
# figure out the urlbase