Patchwork [3,of,5] revset: use 'tiprev' when appropriate

login
register
mail settings
Submitter Boris Feld
Date Jan. 17, 2018, 6:33 p.m.
Message ID <4edcd11f51c89f603cfd.1516214031@FB>
Download mbox | patch
Permalink /patch/26820/
State Accepted
Headers show

Comments

Boris Feld - Jan. 17, 2018, 6:33 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1493857699 -7200
#      Thu May 04 02:28:19 2017 +0200
# Node ID 4edcd11f51c89f603cfdc740d229d141bf544f81
# Parent  048bded89f6f917d7e3514e2318ab3b0af825a34
# EXP-Topic tiprev
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 4edcd11f51c8
revset: use 'tiprev' when appropriate

This is cleaner than the current 'len(repo) - 1' forms

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -124,7 +124,7 @@  def rangeset(repo, subset, x, y, order):
 
 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 @@  def rangepost(repo, subset, x, order):
     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 @@  def _makerangeset(repo, subset, m, n, or
     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: