pushlog: switch custom revset definitions to use `@revsetpredicate` r=gps
authorConnor Sheehan <sheehan@mozilla.com>
Thu, 09 Aug 2018 22:43:38 +0000
changeset 6391 8b4dcd65fa7c
parent 6390 c033db814e2c
child 6392 cbea1bac6707
push id3203
push usergszorc@mozilla.com
push dateThu, 09 Aug 2018 22:43:50 +0000
treeherderversion-control-tools@8b4dcd65fa7c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
pushlog: switch custom revset definitions to use `@revsetpredicate` r=gps Looks like the upstream bug has been fixed for some time, and the tests are passing under 4.6.2. Differential Revision: https://phabricator.services.mozilla.com/D2961
hgext/pushlog/__init__.py
--- a/hgext/pushlog/__init__.py
+++ b/hgext/pushlog/__init__.py
@@ -880,19 +880,17 @@ def pretxnchangegrouphook(ui, repo, node
         return 0
     except Exception as e:
         ui.write('error recording into pushlog (%s); please retry your '
                  'push\n' % e)
 
     return 1
 
 
-# TODO use revsetpredicate once upstream bug
-# https://bz.mercurial-scm.org/show_bug.cgi?id=5601 is resolved.
-#@revsetpredicate('pushhead()', safe=True)
+@revsetpredicate('pushhead()', safe=True)
 def revset_pushhead(repo, subset, x):
     """``pushhead()``
 
     Changesets that were heads when they were pushed.
     """
     revset.getargs(x, 0, 0, 'pushhead takes no arguments')
 
     # Iterating over all pushlog data is unfortunate, as there is overhead
@@ -903,17 +901,17 @@ def revset_pushhead(repo, subset, x):
     def getrevs():
         to_rev = repo.changelog.rev
         for push in repo.pushlog.pushes():
             yield to_rev(bin(push.nodes[-1]))
 
     return subset & revset.generatorset(getrevs())
 
 
-#@revsetpredicate('pushdate(interval)', safe=True)
+@revsetpredicate('pushdate(interval)', safe=True)
 def revset_pushdate(repo, subset, x):
     """``pushdate(interval)``
 
     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')
@@ -924,17 +922,17 @@ def revset_pushdate(repo, subset, x):
         for push in repo.pushlog.pushes():
             if dm(push.when):
                 for node in push.nodes:
                     yield to_rev(bin(node))
 
     return subset & revset.generatorset(getrevs())
 
 
-#@revsetpredicate('pushuser(string)', safe=True)
+@revsetpredicate('pushuser(string)', safe=True)
 def revset_pushuser(repo, subset, x):
     """``pushuser(string)``
 
     User name that pushed the changeset contains string.
 
     The match is case-insensitive.
 
     If `string` starts with `re:`, the remainder of the string is treated as
@@ -950,17 +948,17 @@ def revset_pushuser(repo, subset, x):
         for push in repo.pushlog.pushes():
             if matcher(encoding.lower(push.user)):
                 for node in push.nodes:
                     yield to_rev(bin(node))
 
     return subset & revset.generatorset(getrevs())
 
 
-#@revsetpredicate('pushid(int)', safe=True)
+@revsetpredicate('pushid(int)', safe=True)
 def revset_pushid(repo, subset, x):
     """``pushid(int)``
 
     Changesets that were part of the specified numeric push id.
     """
     l = revset.getargs(x, 1, 1, 'pushid requires one argument')
     try:
         pushid = int(revset.getstring(l[0], 'pushid requires a number'))
@@ -979,17 +977,17 @@ def revset_pushid(repo, subset, x):
         try:
             pushrevs.add(to_rev(bin(node)))
         except RepoLookupError:
             pass
 
     return subset & pushrevs
 
 
-#@revsetpredicate('pushrev(set)', safe=True)
+@revsetpredicate('pushrev(set)', safe=True)
 def revset_pushrev(repo, subset, x):
     """``pushrev(set)``
 
     Changesets that were part of the same push as the specified changeset(s).
     """
     l = revset.getset(repo, subset, x)
 
     # This isn't the most optimal implementation, especially if the input
@@ -1063,28 +1061,16 @@ 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)
 
-    # TODO remove once we switch to @revsetpredicate
-    revset.symbols['pushhead'] = revset_pushhead
-    revset.safesymbols.add('pushhead')
-    revset.symbols['pushdate'] = revset_pushdate
-    revset.safesymbols.add('pushdate')
-    revset.symbols['pushuser'] = revset_pushuser
-    revset.safesymbols.add('pushuser')
-    revset.symbols['pushid'] = revset_pushid
-    revset.safesymbols.add('pushid')
-    revset.symbols['pushrev'] = revset_pushrev
-    revset.safesymbols.add('pushrev')
-
     keywords = {
         'pushid': template_pushid,
         'pushuser': template_pushuser,
         'pushdate': template_pushdate,
         'pushbasenode': template_pushbasenode,
         'pushheadnode': template_pushheadnode,
     }