Patchwork [2,of,3] revset: added sort method to orderedlazyset

login
register
mail settings
Submitter Lucas Moscovicz
Date Feb. 28, 2014, 11:27 p.m.
Message ID <b8f6b9ee7215fa4653cd.1393630070@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3809/
State Accepted
Commit d7e96dd8e995b44d39c2b157857be01dff65425e
Headers show

Comments

Lucas Moscovicz - Feb. 28, 2014, 11:27 p.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@fb.com>
# Date 1393353383 28800
#      Tue Feb 25 10:36:23 2014 -0800
# Node ID b8f6b9ee7215fa4653cd35a623db4c493ea5714c
# Parent  e43e2378c978d1bc53966e32c068fda061748904
revset: added sort method to orderedlazyset

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2249,6 +2249,15 @@ 
         return orderedlazyset(self, lambda r: r not in x,
                 ascending=self._ascending)
 
+    def sort(self, reverse=False):
+        if reverse:
+            if self._ascending:
+                self._subset.sort(reverse=reverse)
+        else:
+            if not self._ascending:
+                self._subset.sort(reverse=reverse)
+        self._ascending = not reverse
+
     def reverse(self):
         self._subset.reverse()
         self._ascending = not self._ascending