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