[PATCH 5 of 5 STABLE v2] revset: use _diffset in orderedlazyset.__sub__

Gregory Szorc gregory.szorc at gmail.com
Mon Sep 8 16:59:47 CDT 2014


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1410200370 25200
#      Mon Sep 08 11:19:30 2014 -0700
# Node ID d2c3dd725cf9b64b564f13096102f61f6b0d06ba
# Parent  b8226fb4800578b0d7b05f255f4c26140e458256
revset: use _diffset in orderedlazyset.__sub__

On a clone of the Firefox repository, the following revsets from the
revset benchmarks demonstrated a statistically significant change.

revset #25: roots((0::) - (0::tip))
wall 447.441994 comb 447.420000 user 447.240000 sys 0.180000 (best of 3)
wall  14.762341 comb  14.770000 user  14.730000 sys 0.040000 (best of 3)

This revset is very similar to one that runs as part of phase boundary
advancement during clone/pull. This change thus makes clones of large
repositories (like Firefox) much faster.

Interestingly, a related revset (roots((tip~100::) - (tip~100::tip)))
showed no statistically significant change.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2414,10 +2414,14 @@ class orderedlazyset(_orderedsetmixin, l
         return orderedlazyset(self, x.__contains__,
                 ascending=self._ascending)
 
     def __sub__(self, x):
-        return orderedlazyset(self, lambda r: r not in x,
-                ascending=self._ascending)
+        kwargs = {}
+        if self.isascending() and x.isascending():
+            kwargs['ascending'] = True
+        if self.isdescending() and x.isdescending():
+            kwargs['ascending'] = False
+        return _diffset(self, x, **kwargs)
 
     def __add__(self, x):
         kwargs = {}
         if self.isascending() and x.isascending():


More information about the Mercurial-devel mailing list