Patchwork transaction-summary: use a revset to filter obsoletes in reportnewcs()

login
register
mail settings
Submitter Denis Laxalde
Date Oct. 16, 2017, 1:35 p.m.
Message ID <4454e61fb17068293bbe.1508160958@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/24977/
State Accepted
Headers show

Comments

Denis Laxalde - Oct. 16, 2017, 1:35 p.m.
# HG changeset patch
# User Denis Laxalde <denis@laxalde.org>
# Date 1508160908 -7200
#      Mon Oct 16 15:35:08 2017 +0200
# Node ID 4454e61fb17068293bbe3cc273e21400e9eb784a
# Parent  115efdd9708811859c466c363311f93b3500a72e
# Available At http://hg.logilab.org/users/dlaxalde/hg
#              hg pull http://hg.logilab.org/users/dlaxalde/hg -r 4454e61fb170
# EXP-Topic pull-info-transaction
transaction-summary: use a revset to filter obsoletes in reportnewcs()

Thanks to Yuya Nishihara for suggesting.
Yuya Nishihara - Oct. 16, 2017, 1:53 p.m.
On Mon, 16 Oct 2017 15:35:58 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis@laxalde.org>
> # Date 1508160908 -7200
> #      Mon Oct 16 15:35:08 2017 +0200
> # Node ID 4454e61fb17068293bbe3cc273e21400e9eb784a
> # Parent  115efdd9708811859c466c363311f93b3500a72e
> # Available At http://hg.logilab.org/users/dlaxalde/hg
> #              hg pull http://hg.logilab.org/users/dlaxalde/hg -r 4454e61fb170
> # EXP-Topic pull-info-transaction
> transaction-summary: use a revset to filter obsoletes in reportnewcs()

Queued, thanks.

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1242,20 +1242,11 @@  def registersummarycallback(repo, otr, t
 
             # Compute the bounds of new revisions' range, excluding obsoletes.
             unfi = repo.unfiltered()
-            minrev, maxrev = None, None
-            newrevs.sort()
-            for r in newrevs:
-                if not unfi[r].obsolete():
-                    minrev = repo[r]
-                    break
-            for r in reversed(newrevs):
-                if not unfi[r].obsolete():
-                    maxrev = repo[r]
-                    break
-
-            if minrev is None or maxrev is None:
+            revs = unfi.revs('%ld and not obsolete()', newrevs)
+            if not revs:
                 # Got only obsoletes.
                 return
+            minrev, maxrev = repo[revs.min()], repo[revs.max()]
 
             if minrev == maxrev:
                 revrange = minrev