mercurial/changegroup.py
changeset 25921 74b303a637bc
parent 25831 578fc97904da
child 26266 1e042e31bd0c
equal deleted inserted replaced
25920:5aaf51c14fea 25921:74b303a637bc
     3 #  Copyright 2006 Matt Mackall <mpm@selenic.com>
     3 #  Copyright 2006 Matt Mackall <mpm@selenic.com>
     4 #
     4 #
     5 # This software may be used and distributed according to the terms of the
     5 # This software may be used and distributed according to the terms of the
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
       
     8 from __future__ import absolute_import
       
     9 
       
    10 import bz2
       
    11 import os
       
    12 import struct
       
    13 import tempfile
     8 import weakref
    14 import weakref
     9 from i18n import _
    15 import zlib
    10 from node import nullrev, nullid, hex, short
    16 
    11 import mdiff, util, dagutil
    17 from .i18n import _
    12 import struct, os, bz2, zlib, tempfile
    18 from .node import (
    13 import discovery, error, phases, branchmap
    19     hex,
       
    20     nullid,
       
    21     nullrev,
       
    22     short,
       
    23 )
       
    24 
       
    25 from . import (
       
    26     branchmap,
       
    27     dagutil,
       
    28     discovery,
       
    29     error,
       
    30     mdiff,
       
    31     phases,
       
    32     util,
       
    33 )
    14 
    34 
    15 _CHANGEGROUPV1_DELTA_HEADER = "20s20s20s20s"
    35 _CHANGEGROUPV1_DELTA_HEADER = "20s20s20s20s"
    16 _CHANGEGROUPV2_DELTA_HEADER = "20s20s20s20s20s"
    36 _CHANGEGROUPV2_DELTA_HEADER = "20s20s20s20s20s"
    17 
    37 
    18 def readexactly(stream, n):
    38 def readexactly(stream, n):
   101             fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg")
   121             fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg")
   102             fh = os.fdopen(fd, "wb")
   122             fh = os.fdopen(fd, "wb")
   103         cleanup = filename
   123         cleanup = filename
   104 
   124 
   105         if bundletype == "HG20":
   125         if bundletype == "HG20":
   106             import bundle2
   126             from . import bundle2
   107             bundle = bundle2.bundle20(ui)
   127             bundle = bundle2.bundle20(ui)
   108             part = bundle.newpart('changegroup', data=cg.getchunks())
   128             part = bundle.newpart('changegroup', data=cg.getchunks())
   109             part.addparam('version', cg.version)
   129             part.addparam('version', cg.version)
   110             z = nocompress()
   130             z = nocompress()
   111             chunkiter = bundle.getchunks()
   131             chunkiter = bundle.getchunks()