changeset 27469:8914296e74a2

commands: use revlog._deltachain in debugdeltachain We have a nice API now. Use it. This does mean we introduce an extra index lookup for each revision. Considering this is a debug command, the overhead should be acceptable. We could add the chain size to revlog._deltachain(). However, that feels like avoidable overhead.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 20 Dec 2015 19:02:02 -0800
parents 93ac15f03331
children d394a1a3708a
files mercurial/commands.py
diffstat 1 files changed, 5 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Dec 20 18:56:05 2015 -0800
+++ b/mercurial/commands.py	Sun Dec 20 19:02:02 2015 -0800
@@ -2542,9 +2542,7 @@
     generaldelta = r.version & revlog.REVLOGGENERALDELTA
 
     def revinfo(rev):
-        iterrev = rev
-        e = index[iterrev]
-        chain = []
+        e = index[rev]
         compsize = e[1]
         uncompsize = e[2]
         chainsize = 0
@@ -2566,19 +2564,11 @@
             else:
                 deltatype = 'prev'
 
-        while iterrev != e[3]:
-            chain.append(iterrev)
+        chain = r._deltachain(rev)[0]
+        for iterrev in chain:
+            e = index[iterrev]
             chainsize += e[1]
-            if generaldelta:
-                iterrev = e[3]
-            else:
-                iterrev -= 1
-            e = index[iterrev]
-        else:
-            chainsize += e[1]
-            chain.append(iterrev)
-
-        chain.reverse()
+
         return compsize, uncompsize, deltatype, chain, chainsize
 
     fm = ui.formatter('debugdeltachain', opts)