revlogstat.py on Windows

Adrian Buehlmann adrian at cadifra.com
Mon Mar 31 12:59:23 CDT 2008


Question from a newbie trying to understand Mercurial source code
(just asking for my own learning):

As already posted, I fail to run Matt's revlogstat python script:
http://selenic.com/pipermail/mercurial/2008-March/018276.html

I would like to ask if anyone has an idea what's wrong with my setup.

I have (slightly modified):

'''
#!/usr/bin/python

import sys
from mercurial import revlog

def stat(f):
    r = revlog.revlog(open, f)
    frags = []
    total = 0
    optimized = 0

    for i in range(r.count()):
        n = r.node(i)
        c = r.length(i)
        total += c
        o = [c]
        for p in r.parentrevs(i):
            if p != -1:
                print 'calling rd = r.revdiff(%s, %s)' % (p, i),
                rd = r.revdiff(p, i)
                print 'len(rd) = %s' % len(rd)
                print 'rd = %s' % repr(rd)
                d = revlog.compress(rd)
                o.append(len(d[0]) + len(d[1]))
        optimized += min(o)
        if not i % 1000:
            print i, total, optimized, "%5.2f" % (100.0 * optimized/total)

    print i, total, optimized, "%5.2f" % (100.0 * optimized/total)

if __name__ == '__main__':
    f = sys.argv[1]
    stat(f)
'''

Running that on my WinXP on a clone of the crew repo:

> python revlogstat.py .hg/store/00manifest.i
0 453 453 100.00
calling rd = r.revdiff(0, 1) len(rd) = 123
rd = '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x003.hgignore\x000c204701e3e88971795a3a2f104a02ebf9dc70e4\n\x00\x00\x002\x00\x00\x00b\x00\x00\x000README\x00
d6f7553376154241dea40dc2af96a8b357f0e991\n'
calling rd = r.revdiff(1, 2) len(rd) = 73
rd = '\x00\x00\x01\xf5\x00\x00\x022\x00\x00\x00=mercurial/revlog.py\x00edd628e83c50e15004dce0207aaab63f8ceb8c97\n'
calling rd = r.revdiff(2, 3) len(rd) = 63
rd = '\x00\x00\x00\x00\x00\x00\x003\x00\x00\x003.hgignore\x00f6b4ffca00cd133e41f32a5f6a3141c1625fe805\n'
calling rd = r.revdiff(3, 4) len(rd) = 69
rd = '\x00\x00\x01\x80\x00\x00\x01\xb9\x00\x00\x009mercurial/hg.py\x007ef8d561b8af849aed51e1e8264f7cd11cd549a5\n'
calling rd = r.revdiff(4, 5) len(rd) = 56
rd = '\x00\x00\x00\x95\x00\x00\x00\xc1\x00\x00\x00,hg\x0006763db6de79098e8cdf14726ca506fdf16749be\n'
calling rd = r.revdiff(5, 6) len(rd) = 63
rd = '\x00\x00\x00\x00\x00\x00\x003\x00\x00\x003.hgignore\x00d219749db2cf96db6397601cde04426fabc85dcf\n'
calling rd = r.revdiff(6, 7) len(rd) = 65
rd = '\x00\x00\x003\x00\x00\x003\x00\x00\x005MANIFEST.in\x00ecf027f3b56bf7fadf8e3dd75cfcd67d8b58deb1\n'
calling rd = r.revdiff(7, 8) len(rd) = 63
rd = '\x00\x00\x00\x00\x00\x00\x003\x00\x00\x003.hgignore\x00708b3e37a5d2b260e303a6d8c0386ca0c18bf41d\n'
calling rd = r.revdiff(8, 9) len(rd) = 69
rd = '\x00\x00\x01\xb5\x00\x00\x01\xee\x00\x00\x009mercurial/hg.py\x00b0e8c6a183c6fd366c189ed39b753d6c41bdd394\n'
calling rd = r.revdiff(9, 10) len(rd) = 69
rd = '\x00\x00\x01\xb5\x00\x00\x01\xee\x00\x00\x009mercurial/hg.py\x001890959ebcf6b06e3e932e5e47bb35eeb30ea2ed\n'
calling rd = r.revdiff(10, 11) len(rd) = 56
rd = '\x00\x00\x00\xca\x00\x00\x00\xf6\x00\x00\x00,hg\x00acc8e2b2f0b3cf17f96725462ed2218b8f9cf82a\n'
calling rd = r.revdiff(11, 12) len(rd) = 78
rd = '\x00\x00\x02g\x00\x00\x02\xa9\x00\x00\x00Bmercurial/transaction.py\x00fc5f24a5755c880dc6d0ac1bd1ea7dbbc84e9a18\n'
calling rd = r.revdiff(12, 13) len(rd) = 78
rd = '\x00\x00\x02g\x00\x00\x02\xa9\x00\x00\x00Bmercurial/transaction.py\x00cb9445eef222b775a0193b9127a9d6690d319e04\n'
calling rd = r.revdiff(13, 14) len(rd) = 73
rd = '\x00\x00\x02*\x00\x00\x02g\x00\x00\x00=mercurial/revlog.py\x00d7516ee9185b882bec7488a7818de86766643e29\n'
calling rd = r.revdiff(14, 15) len(rd) = 69
rd = '\x00\x00\x01\xb5\x00\x00\x01\xee\x00\x00\x009mercurial/hg.py\x00bc6345f2d8b975d8474a658edefd1f0cdb545185\n'
calling rd = r.revdiff(15, 16)
Traceback (most recent call last):
  File "revlogstat.py", line 33, in <module>
    stat(f)
  File "revlogstat.py", line 20, in stat
    rd = r.revdiff(p, i)
  File "C:\Documents and Settings\adi\My Documents\hg-repos\mercurial-crew\mercurial\revlog.py", line 914, in revdiff
    return self.chunk(rev2)
  File "C:\Documents and Settings\adi\My Documents\hg-repos\mercurial-crew\mercurial\revlog.py", line 904, in chunk
    return decompress(c)
  File "C:\Documents and Settings\adi\My Documents\hg-repos\mercurial-crew\mercurial\revlog.py", line 102, in decompress
    return _decompress(bin)
zlib.error: Error -5 while decompressing data


So the call "r.revdiff(15, 16)" fails.

According to http://www.zlib.net/manual.html, error -5 is:

#define Z_BUF_ERROR    (-5)

But I found no further info.

Output of hg debugindex is:

> hg debugindex .hg/store/00manifest.i
   rev    offset  length   base linkrev nodeid       p1           p2
     0         0     453      0       0 ee9b82ca6948 000000000000 000000000000
     1       453     107      0       1 98f3df0f2f4f ee9b82ca6948 000000000000
     2       560      73      0       2 8553cbcb6563 98f3df0f2f4f 000000000000
     3       633      63      0       3 09f628a628a8 8553cbcb6563 000000000000
     4       696      69      0       4 3413f6c67a5a 09f628a628a8 000000000000
     5       765      56      0       5 e45ba20a9362 3413f6c67a5a 000000000000
     6       821      63      0       6 0d3dc5de83cb e45ba20a9362 000000000000
     7       884      65      0       7 79d3ed3443be 0d3dc5de83cb 000000000000
     8       949      63      0       8 cda8ddded379 79d3ed3443be 000000000000
     9      1012      69      0       9 a92b70ad8ab5 cda8ddded379 000000000000
    10      1081      69      0      10 7cf103cd8dc4 a92b70ad8ab5 000000000000
    11      1150      56      0      11 edcf3b74de29 7cf103cd8dc4 000000000000
    12      1206      78      0      12 6fd509a9a2e0 edcf3b74de29 000000000000
    13      1284      78      0      13 0151cbc6d2d7 6fd509a9a2e0 000000000000
    14      1362      73      0      14 9e64605e7ab0 0151cbc6d2d7 000000000000
    15      1435      69      0      15 69d47ab5fc42 9e64605e7ab0 000000000000
    16      1504     111      0      16 81322d98ee1f 69d47ab5fc42 000000000000
    17      1615     525     17      17 20f563caf71e 81322d98ee1f 000000000000
    18      2140      56     17      18 1d47c3ef857a 20f563caf71e 000000000000
    19      2196      69     17      19 09ad4193f64a 1d47c3ef857a 000000000000
    20      2265      69     17      20 7d39a51c424e 09ad4193f64a 000000000000
    21      2334      56     17      21 304d58f819dc 7d39a51c424e 000000000000
    22      2390      56     17      22 3415fc0e0484 304d58f819dc 000000000000
    23      2446      56     17      23 d807e258be8f 3415fc0e0484 000000000000
    24      2502      56     17      24 3e418e872455 d807e258be8f 000000000000
    25      2558      69     17      25 080aa24c9b14 3e418e872455 000000000000

> python -V
Python 2.5.1

What did I miss / am I doing wrong? This looks very strange for me.



More information about the Mercurial mailing list