diff -r 228b0aafb1ce -r 88dad916c008 mercurial/revset.py --- a/mercurial/revset.py Mon Oct 06 11:46:53 2014 -0700 +++ b/mercurial/revset.py Mon Oct 06 11:54:53 2014 -0700 @@ -2862,6 +2862,24 @@ def isdescending(self): return self._start >= self._end + def first(self): + if self._ascending: + it = self.fastasc + else: + it = self.fastdesc + for x in it(): + return x + return None + + def last(self): + if self._ascending: + it = self.fastdesc + else: + it = self.fastasc + for x in it(): + return x + return None + class fullreposet(_spanset): """a set containing all revisions in the repo