commands: use revlog._deltachain in debugdeltachain
authorGregory Szorc <gregory.szorc@gmail.com>
Sun, 20 Dec 2015 19:02:02 -0800
changeset 27469 8914296e74a2
parent 27468 93ac15f03331
child 27470 d394a1a3708a
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.
mercurial/commands.py
--- 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)