Show More
@@ -190,14 +190,18 b' def readgitpatch(patchname):' | |||
|
190 | 190 | def dogitpatch(patchname, gitpatches, cwd=None): |
|
191 | 191 | """Preprocess git patch so that vanilla patch can handle it""" |
|
192 | 192 | def extractbin(fp): |
|
193 | line = fp.readline().rstrip() | |
|
193 | i = [0] # yuck | |
|
194 | def readline(): | |
|
195 | i[0] += 1 | |
|
196 | return fp.readline().rstrip() | |
|
197 | line = readline() | |
|
194 | 198 | while line and not line.startswith('literal '): |
|
195 |
line = |
|
|
199 | line = readline() | |
|
196 | 200 | if not line: |
|
197 | return | |
|
201 | return None, i[0] | |
|
198 | 202 | size = int(line[8:]) |
|
199 | 203 | dec = [] |
|
200 |
line = |
|
|
204 | line = readline() | |
|
201 | 205 | while line: |
|
202 | 206 | l = line[0] |
|
203 | 207 | if l <= 'Z' and l >= 'A': |
@@ -205,12 +209,12 b' def dogitpatch(patchname, gitpatches, cw' | |||
|
205 | 209 | else: |
|
206 | 210 | l = ord(l) - ord('a') + 27 |
|
207 | 211 | dec.append(base85.b85decode(line[1:])[:l]) |
|
208 |
line = |
|
|
212 | line = readline() | |
|
209 | 213 | text = zlib.decompress(''.join(dec)) |
|
210 | 214 | if len(text) != size: |
|
211 | 215 | raise util.Abort(_('binary patch is %d bytes, not %d') % |
|
212 | 216 | (len(text), size)) |
|
213 | return text | |
|
217 | return text, i[0] | |
|
214 | 218 | |
|
215 | 219 | pf = file(patchname) |
|
216 | 220 | pfline = 1 |
@@ -230,9 +234,10 b' def dogitpatch(patchname, gitpatches, cw' | |||
|
230 | 234 | pfline += 1 |
|
231 | 235 | |
|
232 | 236 | if p.binary: |
|
233 | text = extractbin(pf) | |
|
237 | text, delta = extractbin(pf) | |
|
234 | 238 | if not text: |
|
235 | 239 | raise util.Abort(_('binary patch extraction failed')) |
|
240 | pfline += delta | |
|
236 | 241 | if not cwd: |
|
237 | 242 | cwd = os.getcwd() |
|
238 | 243 | absdst = os.path.join(cwd, p.path) |
@@ -162,3 +162,22 b' rename to foo2' | |||
|
162 | 162 | EOF |
|
163 | 163 | cat foo2 |
|
164 | 164 | hg manifest | grep binary |
|
165 | ||
|
166 | echo % many binary files | |
|
167 | hg import -m multibinary - <<EOF | |
|
168 | diff --git a/mbinary1 b/mbinary1 | |
|
169 | new file mode 100644 | |
|
170 | index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4 | |
|
171 | GIT binary patch | |
|
172 | literal 4 | |
|
173 | Lc\${NkU|;|M00aO5 | |
|
174 | ||
|
175 | diff --git a/mbinary2 b/mbinary2 | |
|
176 | new file mode 100644 | |
|
177 | index 0000000000000000000000000000000000000000..112363ac1917b417ffbd7f376ca786a1e5fa7490 | |
|
178 | GIT binary patch | |
|
179 | literal 5 | |
|
180 | Mc\${NkU|\`?^000jF3jhEB | |
|
181 | ||
|
182 | EOF | |
|
183 | hg manifest | grep mbinary |
General Comments 0
You need to be logged in to leave comments.
Login now