Show More
@@ -1022,9 +1022,10 b' class hunk(object):' | |||
|
1022 | 1022 | |
|
1023 | 1023 | class binhunk(object): |
|
1024 | 1024 | 'A binary patch file. Only understands literals so far.' |
|
1025 | def __init__(self, lr): | |
|
1025 | def __init__(self, lr, fname): | |
|
1026 | 1026 | self.text = None |
|
1027 | 1027 | self.hunk = ['GIT binary patch\n'] |
|
1028 | self._fname = fname | |
|
1028 | 1029 | self._read(lr) |
|
1029 | 1030 | |
|
1030 | 1031 | def complete(self): |
@@ -1040,7 +1041,8 b' class binhunk(object):' | |||
|
1040 | 1041 | line = lr.readline() |
|
1041 | 1042 | self.hunk.append(line) |
|
1042 | 1043 | if not line: |
|
1043 |
raise PatchError(_('could not extract binary |
|
|
1044 | raise PatchError(_('could not extract "%s" binary data') | |
|
1045 | % self._fname) | |
|
1044 | 1046 | size = int(line[8:].rstrip()) |
|
1045 | 1047 | dec = [] |
|
1046 | 1048 | line = lr.readline() |
@@ -1054,14 +1056,14 b' class binhunk(object):' | |||
|
1054 | 1056 | try: |
|
1055 | 1057 | dec.append(base85.b85decode(line[1:-1])[:l]) |
|
1056 | 1058 | except ValueError, e: |
|
1057 | raise PatchError(_('could not decode binary patch: %s') | |
|
1058 | % str(e)) | |
|
1059 | raise PatchError(_('could not decode "%s" binary patch: %s') | |
|
1060 | % (self._fname, str(e))) | |
|
1059 | 1061 | line = lr.readline() |
|
1060 | 1062 | self.hunk.append(line) |
|
1061 | 1063 | text = zlib.decompress(''.join(dec)) |
|
1062 | 1064 | if len(text) != size: |
|
1063 |
raise PatchError(_(' |
|
|
1064 | len(text), size) | |
|
1065 | raise PatchError(_('"%s" length is %d bytes, should be %d') | |
|
1066 | % (self._fname, len(text), size)) | |
|
1065 | 1067 | self.text = text |
|
1066 | 1068 | |
|
1067 | 1069 | def parsefilename(str): |
@@ -1200,7 +1202,7 b' def iterhunks(fp):' | |||
|
1200 | 1202 | gitpatches[-1].ispatching(afile, bfile)): |
|
1201 | 1203 | gp = gitpatches.pop() |
|
1202 | 1204 | if x.startswith('GIT binary patch'): |
|
1203 | h = binhunk(lr) | |
|
1205 | h = binhunk(lr, gp.path) | |
|
1204 | 1206 | else: |
|
1205 | 1207 | if context is None and x.startswith('***************'): |
|
1206 | 1208 | context = True |
@@ -364,6 +364,7 b' Move text file and patch as binary' | |||
|
364 | 364 | R text2 |
|
365 | 365 | |
|
366 | 366 | Invalid base85 content |
|
367 | ||
|
367 | 368 | $ hg rollback |
|
368 | 369 | repository tip rolled back to revision 15 (undo import) |
|
369 | 370 | working directory now based on revision 15 |
@@ -379,8 +380,38 b' Invalid base85 content' | |||
|
379 | 380 | > |
|
380 | 381 | > EOF |
|
381 | 382 | applying patch from stdin |
|
382 | abort: could not decode binary patch: bad base85 character at position 6 | |
|
383 | abort: could not decode "binary2" binary patch: bad base85 character at position 6 | |
|
383 | 384 | [255] |
|
385 | ||
|
386 | $ hg revert -aq | |
|
387 | $ hg import -d "1000000 0" -m rename-as-binary - <<"EOF" | |
|
388 | > diff --git a/text2 b/binary2 | |
|
389 | > rename from text2 | |
|
390 | > rename to binary2 | |
|
391 | > index 78981922613b2afb6025042ff6bd878ac1994e85..10efcb362e9f3b3420fcfbfc0e37f3dc16e29757 | |
|
392 | > GIT binary patch | |
|
393 | > literal 6 | |
|
394 | > Mc$`b*O5$Pw00T?_*Z=?k | |
|
395 | > | |
|
396 | > EOF | |
|
397 | applying patch from stdin | |
|
398 | abort: "binary2" length is 5 bytes, should be 6 | |
|
399 | [255] | |
|
400 | ||
|
401 | $ hg revert -aq | |
|
402 | $ hg import -d "1000000 0" -m rename-as-binary - <<"EOF" | |
|
403 | > diff --git a/text2 b/binary2 | |
|
404 | > rename from text2 | |
|
405 | > rename to binary2 | |
|
406 | > index 78981922613b2afb6025042ff6bd878ac1994e85..10efcb362e9f3b3420fcfbfc0e37f3dc16e29757 | |
|
407 | > GIT binary patch | |
|
408 | > Mc$`b*O5$Pw00T?_*Z=?k | |
|
409 | > | |
|
410 | > EOF | |
|
411 | applying patch from stdin | |
|
412 | abort: could not extract "binary2" binary data | |
|
413 | [255] | |
|
414 | ||
|
384 | 415 | $ cd .. |
|
385 | 416 | |
|
386 | 417 | Consecutive import with renames (issue2459) |
General Comments 0
You need to be logged in to leave comments.
Login now