From patchwork Fri Feb 28 23:27:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,3] revset: changed methods in spanset to return ordered sets From: Lucas Moscovicz X-Patchwork-Id: 3811 Message-Id: <320e4050c7b95213780f.1393630071@dev1037.prn2.facebook.com> To: mercurial-devel@selenic.com Date: Fri, 28 Feb 2014 15:27:51 -0800 # HG changeset patch # User Lucas Moscovicz # Date 1392757628 28800 # Tue Feb 18 13:07:08 2014 -0800 # Node ID 320e4050c7b95213780f735dab11babc7aac2dcd # Parent b8f6b9ee7215fa4653cd35a623db4c493ea5714c revset: changed methods in spanset to return ordered sets Now __sub__ and __and__ can smartly return ordered lazysets. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -2363,12 +2363,18 @@ def __and__(self, x): if isinstance(x, baseset): x = x.set() - return lazyset(self, lambda r: r in x) + if self._start <= self._end: + return orderedlazyset(self, lambda r: r in x) + else: + return orderedlazyset(self, lambda r: r in x, ascending=False) def __sub__(self, x): if isinstance(x, baseset): x = x.set() - return lazyset(self, lambda r: r not in x) + if self._start <= self._end: + return orderedlazyset(self, lambda r: r not in x) + else: + return orderedlazyset(self, lambda r: r not in x, ascending=False) def __add__(self, x): l = baseset(self)