[PATCH] transaction-summary: use a revset to filter obsoletes in reportnewcs()

Denis Laxalde denis at laxalde.org
Mon Oct 16 13:35:58 UTC 2017


# HG changeset patch
# User Denis Laxalde <denis at 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.

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


More information about the Mercurial-devel mailing list