hgext/remotefilelog/debugcommands.py
changeset 40507 e2a1584e9e3f
parent 40495 3a333a582d7b
child 40510 fc2766860796
equal deleted inserted replaced
40506:10c10da14c5d 40507:e2a1584e9e3f
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 from __future__ import absolute_import
     7 from __future__ import absolute_import
     8 
     8 
     9 import hashlib
     9 import hashlib
    10 import os
    10 import os
       
    11 import zlib
    11 
    12 
    12 from mercurial.node import bin, hex, nullid, short
    13 from mercurial.node import bin, hex, nullid, short
    13 from mercurial.i18n import _
    14 from mercurial.i18n import _
    14 from mercurial import (
    15 from mercurial import (
    15     error,
    16     error,
    20     constants,
    21     constants,
    21     datapack,
    22     datapack,
    22     extutil,
    23     extutil,
    23     fileserverclient,
    24     fileserverclient,
    24     historypack,
    25     historypack,
    25     lz4wrapper,
       
    26     repack,
    26     repack,
    27     shallowrepo,
    27     shallowrepo,
    28     shallowutil,
    28     shallowutil,
    29 )
    29 )
    30 
    30 
   169                     key = fileserverclient.getcachekey("reponame", actualpath,
   169                     key = fileserverclient.getcachekey("reponame", actualpath,
   170                                                        file)
   170                                                        file)
   171                     ui.status("%s %s\n" % (key, os.path.relpath(filepath,
   171                     ui.status("%s %s\n" % (key, os.path.relpath(filepath,
   172                                                                 path)))
   172                                                                 path)))
   173 
   173 
       
   174 def _decompressblob(raw):
       
   175     return zlib.decompress(raw)
       
   176 
   174 def parsefileblob(path, decompress):
   177 def parsefileblob(path, decompress):
   175     raw = None
   178     raw = None
   176     f = open(path, "r")
   179     f = open(path, "r")
   177     try:
   180     try:
   178         raw = f.read()
   181         raw = f.read()
   179     finally:
   182     finally:
   180         f.close()
   183         f.close()
   181 
   184 
   182     if decompress:
   185     if decompress:
   183         raw = lz4wrapper.lz4decompress(raw)
   186         raw = _decompressblob(raw)
   184 
   187 
   185     offset, size, flags = shallowutil.parsesizeflags(raw)
   188     offset, size, flags = shallowutil.parsesizeflags(raw)
   186     start = offset + size
   189     start = offset + size
   187 
   190 
   188     firstnode = None
   191     firstnode = None