D5687: revpair: simplify revpair by always relying on smartset.first/last

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Jan 24 20:51:22 UTC 2019


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I thinkt the code was written the way it was because it comes from
  https://phab.mercurial-scm.org/rHG97b2f26dfc43be63ef48f7cdddfb984ecfd462fc (revpair: smartset compatibility, 2014-03-20) and the
  first/last methods came only later, in https://phab.mercurial-scm.org/rHG228b0aafb1ce51cb9a525343c69f53c880c6c659 (smartset: add
  first and last methods, 2014-10-06).

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5687

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -672,17 +672,8 @@
 
     l = revrange(repo, revs)
 
-    if not l:
-        first = second = None
-    elif l.isascending():
-        first = l.min()
-        second = l.max()
-    elif l.isdescending():
-        first = l.max()
-        second = l.min()
-    else:
-        first = l.first()
-        second = l.last()
+    first = l.first()
+    second = l.last()
 
     if first is None:
         raise error.Abort(_('empty revision range'))



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list