revsets: add first alias for last
authorMatt Mackall <mpm@selenic.com>
Sat, 17 Sep 2011 12:34:47 -0500
changeset 15117 0ab1c3a1f3b2
parent 15116 d8501bcbb221
child 15118 9a1438f6af5f
revsets: add first alias for last
mercurial/revset.py
--- a/mercurial/revset.py	Fri Sep 16 22:57:47 2011 -0500
+++ b/mercurial/revset.py	Sat Sep 17 12:34:47 2011 -0500
@@ -407,6 +407,12 @@
 
     return [r for r in subset if r in s]
 
+def first(repo, subset, x):
+    """``first(set, [n])``
+    An alias for limit().
+    """
+    return limit(repo, subset, x)
+
 def follow(repo, subset, x):
     """``follow([file])``
     An alias for ``::.`` (ancestors of the working copy's first parent).
@@ -842,6 +848,7 @@
     "descendants": descendants,
     "file": hasfile,
     "filelog": filelog,
+    "first": first,
     "follow": follow,
     "grep": grep,
     "head": head,
@@ -955,7 +962,7 @@
             w = 100 # very slow
         elif f == "ancestor":
             w = 1 * smallbonus
-        elif f in "reverse limit":
+        elif f in "reverse limit first":
             w = 0
         elif f in "sort":
             w = 10 # assume most sorts look at changelog