--- a/hgext/pushlog/__init__.py
+++ b/hgext/pushlog/__init__.py
@@ -26,22 +26,25 @@ from mercurial import (
)
from mercurial.hgweb import (
webutil,
)
Abort = error.Abort
RepoLookupError = error.RepoLookupError
+minimumhgversion = '3.7'
testedwith = '3.7'
buglink = 'https://bugzilla.mozilla.org/enter_bug.cgi?product=Developer%20Services&component=Mercurial%3A%20Pushlog'
cmdtable = {}
command = cmdutil.command(cmdtable)
+revsetpredicate = revset.extpredicate()
+
SCHEMA = [
'CREATE TABLE IF NOT EXISTS changesets (pushid INTEGER, rev INTEGER, node text)',
'CREATE TABLE IF NOT EXISTS pushlog (id INTEGER PRIMARY KEY AUTOINCREMENT, user TEXT, date INTEGER)',
'CREATE UNIQUE INDEX IF NOT EXISTS changeset_node ON changesets (node)',
'CREATE UNIQUE INDEX IF NOT EXISTS changeset_rev ON changesets (rev)',
'CREATE INDEX IF NOT EXISTS changeset_pushid ON changesets (pushid)',
'CREATE INDEX IF NOT EXISTS pushlog_date ON pushlog (date)',
'CREATE INDEX IF NOT EXISTS pushlog_user ON pushlog (user)',
@@ -556,57 +559,56 @@ def pretxnchangegrouphook(ui, repo, node
repo.pushlog.recordpush(revs, pushuser, t)
ui.write('recorded push in pushlog\n')
return 0
except Exception:
ui.write('error recording into pushlog; please retry your push\n')
return 1
+@revsetpredicate('pushhead()')
def revset_pushhead(repo, subset, x):
- """``pushhead()``
- Changesets that were heads when they were pushed.
+ """Changesets that were heads when they were pushed.
A push head is a changeset that was a head at the time it was pushed.
"""
revset.getargs(x, 0, 0, 'pushhead takes no arguments')
# Iterating over all pushlog data is unfortunate, as there is overhead
# involved. However, this is less overhead than issuing a SQL query for
# every changeset, especially on large repositories. There is room to make
# this optimal by batching SQL, but that adds complexity. For now,
# simplicity wins.
def getrevs():
for push in repo.pushlog.pushes():
yield repo[push.nodes[-1]].rev()
return subset & revset.generatorset(getrevs())
+@revsetpredicate('pushdate(interval)')
def revset_pushdate(repo, subset, x):
- """``pushdate(interval)``
- Changesets that were pushed within the interval, see :hg:`help dates`.
- """
+ """Changesets that were pushed within the interval, see :hg:`help dates`."""
l = revset.getargs(x, 1, 1, 'pushdate requires one argument')
ds = revset.getstring(l[0], 'pushdate requires a string argument')
dm = util.matchdate(ds)
def getrevs():
for push in repo.pushlog.pushes():
if dm(push.when):
for node in push.nodes:
yield repo[node].rev()
return subset & revset.generatorset(getrevs())
+@revsetpredicate('pushuser(string)')
def revset_pushuser(repo, subset, x):
- """``pushuser(string)``
+ """User name that pushed the changeset contains string.
- User name that pushed the changeset contains string. The match is
- case-insensitive.
+ The match is case-insensitive.
If `string` starts with `re:`, the remainder of the string is treated as
a regular expression. To match a user that actually contains `re:`, use
the prefix `literal:`.
"""
l = revset.getargs(x, 1, 1, 'pushuser requires one argument')
n = encoding.lower(revset.getstring(l[0], 'pushuser requires a string'))
kind, pattern, matcher = revset._substringmatcher(n)
@@ -678,19 +680,17 @@ def template_pushheadnode(repo, ctx, tem
def verifypushlog(ui, repo):
"""Verify the pushlog data looks correct."""
return repo.pushlog.verify()
def extsetup(ui):
extensions.wrapfunction(wireproto, '_capabilities', capabilities)
extensions.wrapfunction(exchange, '_pullobsolete', exchangepullpushlog)
- revset.symbols['pushhead'] = revset_pushhead
- revset.symbols['pushdate'] = revset_pushdate
- revset.symbols['pushuser'] = revset_pushuser
+ revsetpredicate.setup()
keywords = {
'pushid': template_pushid,
'pushuser': template_pushuser,
'pushdate': template_pushdate,
'pushbasenode': template_pushbasenode,
'pushheadnode': template_pushheadnode,
}