Mercurial > hg-stable
changeset 22812:fcd12b310148
baseset: implement `first` and `last` methods
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 06 Oct 2014 14:42:00 -0700 |
parents | c1fd827e1ae0 |
children | 5a96df266b2b |
files | mercurial/revset.py |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Mon Oct 06 12:52:36 2014 -0700 +++ b/mercurial/revset.py Mon Oct 06 14:42:00 2014 -0700 @@ -2387,6 +2387,16 @@ This is part of the mandatory API for smartset.""" return False + def first(self): + if self: + return self[0] + return None + + def last(self): + if self: + return self[-1] + return None + class filteredset(abstractsmartset): """Duck type for baseset class which iterates lazily over the revisions in the subset and contains a function which tests for membership in the