##// END OF EJS Templates
bundle2: print debug information during unbundling...
Pierre-Yves David -
r20843:0641b41b default
parent child Browse files
Show More
@@ -141,7 +141,8 b' class unbundle20(object):'
141
141
142 (this will eventually yield parts)"""
142 (this will eventually yield parts)"""
143
143
144 def __init__(self, fp):
144 def __init__(self, ui, fp):
145 self.ui = ui
145 self._fp = fp
146 self._fp = fp
146 header = self._readexact(4)
147 header = self._readexact(4)
147 magic, version = header[0:2], header[2:4]
148 magic, version = header[0:2], header[2:4]
@@ -149,6 +150,7 b' class unbundle20(object):'
149 raise util.Abort(_('not a Mercurial bundle'))
150 raise util.Abort(_('not a Mercurial bundle'))
150 if version != '20':
151 if version != '20':
151 raise util.Abort(_('unknown bundle version %s') % version)
152 raise util.Abort(_('unknown bundle version %s') % version)
153 self.ui.debug('start processing of %s stream\n' % header)
152
154
153 def _unpack(self, format):
155 def _unpack(self, format):
154 """unpack this struct format from the stream"""
156 """unpack this struct format from the stream"""
@@ -162,6 +164,7 b' class unbundle20(object):'
162 @util.propertycache
164 @util.propertycache
163 def params(self):
165 def params(self):
164 """dictionnary of stream level parameters"""
166 """dictionnary of stream level parameters"""
167 self.ui.debug('reading bundle2 stream parameters\n')
165 params = {}
168 params = {}
166 paramssize = self._unpack(_fstreamparamsize)[0]
169 paramssize = self._unpack(_fstreamparamsize)[0]
167 if paramssize:
170 if paramssize:
@@ -177,10 +180,12 b' class unbundle20(object):'
177 """yield all parts contained in the stream"""
180 """yield all parts contained in the stream"""
178 # make sure param have been loaded
181 # make sure param have been loaded
179 self.params
182 self.params
183 self.ui.debug('start extraction of bundle2 parts\n')
180 part = self._readpart()
184 part = self._readpart()
181 while part is not None:
185 while part is not None:
182 yield part
186 yield part
183 part = self._readpart()
187 part = self._readpart()
188 self.ui.debug('end of bundle2 stream\n')
184
189
185 def _readpart(self):
190 def _readpart(self):
186 """return None when an end of stream markers is reach"""
191 """return None when an end of stream markers is reach"""
@@ -39,7 +39,7 b' Create an extension to test bundle2 API'
39 > @command('unbundle2', [], '')
39 > @command('unbundle2', [], '')
40 > def cmdunbundle2(ui, repo):
40 > def cmdunbundle2(ui, repo):
41 > """read a bundle2 container from standard input"""
41 > """read a bundle2 container from standard input"""
42 > unbundler = bundle2.unbundle20(sys.stdin)
42 > unbundler = bundle2.unbundle20(ui, sys.stdin)
43 > ui.write('options count: %i\n' % len(unbundler.params))
43 > ui.write('options count: %i\n' % len(unbundler.params))
44 > for key in sorted(unbundler.params):
44 > for key in sorted(unbundler.params):
45 > ui.write('- %s\n' % key)
45 > ui.write('- %s\n' % key)
@@ -162,6 +162,8 b' Test unbundling'
162 Test debug output
162 Test debug output
163 ---------------------------------------------------
163 ---------------------------------------------------
164
164
165 bundling debug
166
165 $ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2
167 $ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2
166 start emission of HG20 stream
168 start emission of HG20 stream
167 bundle parameter: e%7C%21%207/=babar%25%23%3D%3Dtutu simple
169 bundle parameter: e%7C%21%207/=babar%25%23%3D%3Dtutu simple
@@ -172,6 +174,20 b' file content is ok'
172 $ cat ../out.hg2
174 $ cat ../out.hg2
173 HG20\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
175 HG20\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
174
176
177 unbundling debug
178
179 $ hg unbundle2 --debug < ../out.hg2
180 start processing of HG20 stream
181 reading bundle2 stream parameters
182 options count: 2
183 - e|! 7/
184 babar%#==tutu
185 - simple
186 start extraction of bundle2 parts
187 end of bundle2 stream
188 parts count: 0
189
190
175 Test buggy input
191 Test buggy input
176 ---------------------------------------------------
192 ---------------------------------------------------
177
193
General Comments 0
You need to be logged in to leave comments. Login now