Patchwork [1,of,2] baseset: keep the input set around

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 21, 2015, 10:58 p.m.
Message ID <76e8706080029160e4b7.1440197921@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/10249/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 21, 2015, 10:58 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1440116396 25200
#      Thu Aug 20 17:19:56 2015 -0700
# Node ID 76e8706080029160e4b71b043ac20b2760516eab
# Parent  d9d3d49c4cf77049d12920980e91bf8e4a4ecda2
baseset: keep the input set around

Baseset needs a list to operate, but will convert that list back to a set for
membership testing. It seems a bit silly to convert the set into a list to
convert is back afterward.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2964,10 +2964,12 @@  class baseset(abstractsmartset):
 
     Every method in this class should be implemented by any smartset class.
     """
     def __init__(self, data=()):
         if not isinstance(data, list):
+            if isinstance(data, set):
+                self._set = data
             data = list(data)
         self._list = data
         self._ascending = None
 
     @util.propertycache