Patchwork [5,of,5] win32text: use 'tiprev' when appropriate

login
register
mail settings
Submitter Boris Feld
Date Jan. 17, 2018, 6:33 p.m.
Message ID <7ce8b78bbed0684bcd55.1516214033@FB>
Download mbox | patch
Permalink /patch/26823/
State Accepted
Headers show

Comments

Boris Feld - Jan. 17, 2018, 6:33 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1516190562 -3600
#      Wed Jan 17 13:02:42 2018 +0100
# Node ID 7ce8b78bbed0684bcd5529beb83cc04a8c456c34
# Parent  f345503e9327bb9a2967f5f75b3a49ecb302afc0
# EXP-Topic tiprev
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 7ce8b78bbed0
win32text: use 'tiprev' when appropriate

This is cleaner than the current 'len(repo) - 1' form.
via Mercurial-devel - Jan. 18, 2018, 5:31 a.m.
Queued (actually many hours ago, but I forgot to let you know until
now). Thank you.

On Wed, Jan 17, 2018 at 10:33 AM, Boris Feld <boris.feld@octobus.net> wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1516190562 -3600
> #      Wed Jan 17 13:02:42 2018 +0100
> # Node ID 7ce8b78bbed0684bcd5529beb83cc04a8c456c34
> # Parent  f345503e9327bb9a2967f5f75b3a49ecb302afc0
> # EXP-Topic tiprev
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 7ce8b78bbed0
> win32text: use 'tiprev' when appropriate
>
> This is cleaner than the current 'len(repo) - 1' form.
>
> diff --git a/hgext/win32text.py b/hgext/win32text.py
> --- a/hgext/win32text.py
> +++ b/hgext/win32text.py
> @@ -139,7 +139,7 @@ def forbidnewline(ui, repo, hooktype, no
>      # changegroup that contains an unacceptable commit followed later
>      # by a commit that fixes the problem.
>      tip = repo['tip']
> -    for rev in xrange(len(repo) - 1, repo[node].rev() - 1, -1):
> +    for rev in xrange(repo.changelog.tiprev(), repo[node].rev() - 1, -1):
>          c = repo[rev]
>          for f in c.files():
>              if f in seen or f not in tip or f not in c:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/win32text.py b/hgext/win32text.py
--- a/hgext/win32text.py
+++ b/hgext/win32text.py
@@ -139,7 +139,7 @@  def forbidnewline(ui, repo, hooktype, no
     # changegroup that contains an unacceptable commit followed later
     # by a commit that fixes the problem.
     tip = repo['tip']
-    for rev in xrange(len(repo) - 1, repo[node].rev() - 1, -1):
+    for rev in xrange(repo.changelog.tiprev(), repo[node].rev() - 1, -1):
         c = repo[rev]
         for f in c.files():
             if f in seen or f not in tip or f not in c: