Submitter | Lucas Moscovicz |
---|---|
Date | Feb. 12, 2014, 10:39 p.m. |
Message ID | <35e93209ef29f7869112.1392244797@dev1037.prn2.facebook.com> |
Download | mbox | patch |
Permalink | /patch/3628/ |
State | Superseded |
Headers | show |
Comments
On Wed, 2014-02-12 at 14:39 -0800, Lucas Moscovicz wrote: > # HG changeset patch > # User Lucas Moscovicz <lmoscovicz@fb.com> > # Date 1391791458 28800 > # Fri Feb 07 08:44:18 2014 -0800 > # Node ID 35e93209ef29f786911232f9f37ad95661abf3d9 > # Parent 1cc650bf69c051609ef85d955d7562cbf9285743 > revset: added order property to lazyset classes This looks promising. Using strings for the direction names is a bit unfortunate though. Perhaps we can do something like this: def ascending(self): # true if we can -efficiently- traverse this set in ascending order def descending(self): # true if we can -efficiently- traverse this set in descending order Both of these would be true for lazyset and spanset. And then we can make algorithms that are conditional on these.
On 02/14/2014 09:49 AM, Matt Mackall wrote: > On Wed, 2014-02-12 at 14:39 -0800, Lucas Moscovicz wrote: >> # HG changeset patch >> # User Lucas Moscovicz <lmoscovicz@fb.com> >> # Date 1391791458 28800 >> # Fri Feb 07 08:44:18 2014 -0800 >> # Node ID 35e93209ef29f786911232f9f37ad95661abf3d9 >> # Parent 1cc650bf69c051609ef85d955d7562cbf9285743 >> revset: added order property to lazyset classes > > This looks promising. Using strings for the direction names is a bit > unfortunate though. > > Perhaps we can do something like this: > > def ascending(self): > # true if we can -efficiently- traverse this set in ascending order > > def descending(self): > # true if we can -efficiently- traverse this set in descending order If we can use more attribute instead of function call that would help to avoid the Python slowness.
Patch
diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -2070,6 +2070,10 @@ super(baseset, self).__init__(data) self._set = None + @property + def order(self): + return None + def set(self): if not self._set: self._set = set(self) @@ -2105,6 +2109,10 @@ self._condition = condition self._ncache = set() + @property + def order(self): + return None + def __contains__(self, x): if x in self._ncache: return False @@ -2154,6 +2162,10 @@ return lazyset(self, l) class asclazyset(lazyset): + @property + def order(self): + return 'asc' + def filter(self, l): return asclazyset(self, l) @@ -2164,6 +2176,10 @@ return asclazyset(self, lambda r: r not in x) class desclazyset(lazyset): + @property + def order(self): + return 'desc' + def filter(self, l): return desclazyset(self, l) @@ -2259,6 +2275,13 @@ self._end = end self._hiddenrevs = hiddenrevs + @property + def order(self): + if self._start <= self._end: + return 'asc' + else: + return 'desc' + def _hidden(self, rev): return self._hiddenrevs and rev in self._hiddenrevs