comparison mercurial/bundle2.py @ 20842:938718d72624

bundle2: print debug information during bundling The bundler class is now feed with an ui object and use it to transmit data about the bundling process.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 18 Mar 2014 19:07:10 -0700
parents 8532f5e1b9df
children 0641b41b0b49
comparison
equal deleted inserted replaced
20841:cff562fe77a0 20842:938718d72624
95 `getchunks` to retrieve all the binary chunks of datathat compose the 95 `getchunks` to retrieve all the binary chunks of datathat compose the
96 bundle2 container. 96 bundle2 container.
97 97
98 This object does not support payload part yet.""" 98 This object does not support payload part yet."""
99 99
100 def __init__(self): 100 def __init__(self, ui):
101 self.ui = ui
101 self._params = [] 102 self._params = []
102 self._parts = [] 103 self._parts = []
103 104
104 def addparam(self, name, value=None): 105 def addparam(self, name, value=None):
105 """add a stream level parameter""" 106 """add a stream level parameter"""
108 if name[0] not in string.letters: 109 if name[0] not in string.letters:
109 raise ValueError('non letter first character: %r' % name) 110 raise ValueError('non letter first character: %r' % name)
110 self._params.append((name, value)) 111 self._params.append((name, value))
111 112
112 def getchunks(self): 113 def getchunks(self):
114 self.ui.debug('start emission of %s stream\n' % _magicstring)
113 yield _magicstring 115 yield _magicstring
114 param = self._paramchunk() 116 param = self._paramchunk()
117 self.ui.debug('bundle parameter: %s\n' % param)
115 yield _pack(_fstreamparamsize, len(param)) 118 yield _pack(_fstreamparamsize, len(param))
116 if param: 119 if param:
117 yield param 120 yield param
118 121
119 # no support for parts 122 # no support for parts
120 # to be obviously fixed soon. 123 # to be obviously fixed soon.
121 assert not self._parts 124 assert not self._parts
125 self.ui.debug('end of bundle\n')
122 yield '\0\0' 126 yield '\0\0'
123 127
124 def _paramchunk(self): 128 def _paramchunk(self):
125 """return a encoded version of all stream parameters""" 129 """return a encoded version of all stream parameters"""
126 blocks = [] 130 blocks = []