diff -r 12450fbea288 -r 7431f5ab0d2a hgext/git/gitlog.py --- a/hgext/git/gitlog.py Fri Apr 30 02:11:58 2021 +0200 +++ b/hgext/git/gitlog.py Mon May 03 18:55:19 2021 +0200 @@ -65,7 +65,8 @@ def hasnode(self, n): t = self._db.execute( - 'SELECT node FROM changelog WHERE node = ?', (n,) + 'SELECT node FROM changelog WHERE node = ?', + (pycompat.sysstr(n),), ).fetchone() return t is not None @@ -144,7 +145,7 @@ def revs(self, start=0, stop=None): if stop is None: - stop = self.tip() + stop = self.tiprev() t = self._db.execute( 'SELECT rev FROM changelog ' 'WHERE rev >= ? AND rev <= ? ' @@ -156,8 +157,11 @@ def tiprev(self): t = self._db.execute( 'SELECT rev FROM changelog ' 'ORDER BY REV DESC ' 'LIMIT 1' - ) - return next(t) + ).fetchone() + + if t is not None: + return t[0] + return -1 def _partialmatch(self, id): if sha1nodeconstants.wdirhex.startswith(id): @@ -165,7 +169,8 @@ candidates = [ bin(x[0]) for x in self._db.execute( - 'SELECT node FROM changelog WHERE node LIKE ?', (id + b'%',) + 'SELECT node FROM changelog WHERE node LIKE ?', + (pycompat.sysstr(id + b'%'),), ) ] if sha1nodeconstants.nullhex.startswith(id): @@ -213,10 +218,11 @@ n = self.node(nodeorrev) else: n = nodeorrev + extra = {b'branch': b'default'} # handle looking up nullid if n == sha1nodeconstants.nullid: return hgchangelog._changelogrevision( - extra={}, manifest=sha1nodeconstants.nullid + extra=extra, manifest=sha1nodeconstants.nullid ) hn = gitutil.togitnode(n) # We've got a real commit! @@ -233,7 +239,7 @@ for r in self._db.execute( 'SELECT filename FROM changedfiles ' 'WHERE node = ? and filenode = ?', - (hn, sha1nodeconstants.nullhex), + (hn, gitutil.nullgit), ) ] c = self.gitrepo[hn] @@ -247,7 +253,7 @@ filesremoved=filesremoved, description=c.message.encode('utf8'), # TODO do we want to handle extra? how? - extra={b'branch': b'default'}, + extra=extra, ) def ancestors(self, revs, stoprev=0, inclusive=False):