revset: use 'tiprev' when appropriate
authorBoris Feld <boris.feld@octobus.net>
Thu, 04 May 2017 02:28:19 +0200
changeset 35673 134ef400cb11
parent 35672 5a6e0eee7781
child 35674 e711906aa42c
revset: use 'tiprev' when appropriate This is cleaner than the current 'len(repo) - 1' forms
mercurial/revset.py
--- a/mercurial/revset.py	Thu May 04 02:24:04 2017 +0200
+++ b/mercurial/revset.py	Thu May 04 02:28:19 2017 +0200
@@ -124,7 +124,7 @@
 
 def rangeall(repo, subset, x, order):
     assert x is None
-    return _makerangeset(repo, subset, 0, len(repo) - 1, order)
+    return _makerangeset(repo, subset, 0, repo.changelog.tiprev(), order)
 
 def rangepre(repo, subset, y, order):
     # ':y' can't be rewritten to '0:y' since '0' may be hidden
@@ -137,7 +137,8 @@
     m = getset(repo, fullreposet(repo), x)
     if not m:
         return baseset()
-    return _makerangeset(repo, subset, m.first(), len(repo) - 1, order)
+    return _makerangeset(repo, subset, m.first(), repo.changelog.tiprev(),
+                         order)
 
 def _makerangeset(repo, subset, m, n, order):
     if m == n:
@@ -145,7 +146,7 @@
     elif n == node.wdirrev:
         r = spanset(repo, m, len(repo)) + baseset([n])
     elif m == node.wdirrev:
-        r = baseset([m]) + spanset(repo, len(repo) - 1, n - 1)
+        r = baseset([m]) + spanset(repo, repo.changelog.tiprev(), n - 1)
     elif m < n:
         r = spanset(repo, m, n + 1)
     else: