# HG changeset patch # User Pierre-Yves David # Date 2014-10-06 21:42:00 # Node ID fcd12b3101483e8f6418f82f7ef7f32bc411e61d # Parent c1fd827e1ae0614a02fd8a7e34ce0b7f9bf32b46 baseset: implement `first` and `last` methods diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -2387,6 +2387,16 @@ class baseset(list, abstractsmartset): 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