Patchwork [1,of,3,STABLE] notify: use changelog API to iterate over revision number (issue5821)

login
register
mail settings
Submitter Boris Feld
Date April 19, 2018, 9:17 a.m.
Message ID <e4f85af0d409055650ee.1524129427@FB>
Download mbox | patch
Permalink /patch/31196/
State Accepted
Headers show

Comments

Boris Feld - April 19, 2018, 9:17 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1524056652 -7200
#      Wed Apr 18 15:04:12 2018 +0200
# Branch stable
# Node ID e4f85af0d409055650ee05d18596532bd08747d4
# Parent  afa8126a884b7ad4ba3c34533326a3ea336e6ab2
# EXP-Topic issue5821
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e4f85af0d409
notify: use changelog API to iterate over revision number (issue5821)

This will avoid iterating over filtered revision.
Yuya Nishihara - April 19, 2018, 11:18 a.m.
On Thu, 19 Apr 2018 11:17:07 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1524056652 -7200
> #      Wed Apr 18 15:04:12 2018 +0200
> # Branch stable
> # Node ID e4f85af0d409055650ee05d18596532bd08747d4
> # Parent  afa8126a884b7ad4ba3c34533326a3ea336e6ab2
> # EXP-Topic issue5821
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e4f85af0d409
> notify: use changelog API to iterate over revision number (issue5821)

Queued for stable, thanks.

Can you add some tests as a follow up?

Patch

diff --git a/hgext/notify.py b/hgext/notify.py
--- a/hgext/notify.py
+++ b/hgext/notify.py
@@ -469,8 +469,7 @@  def hook(ui, repo, hooktype, node=None, 
     count = 0
     author = ''
     if hooktype == 'changegroup' or hooktype == 'outgoing':
-        start, end = ctx.rev(), len(repo)
-        for rev in xrange(start, end):
+        for rev in repo.changelog.revs(start=ctx.rev()):
             if n.node(repo[rev]):
                 count += 1
                 if not author: