Show More
@@ -1035,18 +1035,20 b' class binhunk(object):' | |||||
1035 | return [self.text] |
|
1035 | return [self.text] | |
1036 |
|
1036 | |||
1037 | def _read(self, lr): |
|
1037 | def _read(self, lr): | |
1038 | line = lr.readline() |
|
1038 | def getline(lr, hunk): | |
1039 | self.hunk.append(line) |
|
1039 | l = lr.readline() | |
|
1040 | hunk.append(l) | |||
|
1041 | return l.rstrip('\r\n') | |||
|
1042 | ||||
|
1043 | line = getline(lr, self.hunk) | |||
1040 | while line and not line.startswith('literal '): |
|
1044 | while line and not line.startswith('literal '): | |
1041 |
line = lr. |
|
1045 | line = getline(lr, self.hunk) | |
1042 | self.hunk.append(line) |
|
|||
1043 | if not line: |
|
1046 | if not line: | |
1044 | raise PatchError(_('could not extract "%s" binary data') |
|
1047 | raise PatchError(_('could not extract "%s" binary data') | |
1045 | % self._fname) |
|
1048 | % self._fname) | |
1046 | size = int(line[8:].rstrip()) |
|
1049 | size = int(line[8:].rstrip()) | |
1047 | dec = [] |
|
1050 | dec = [] | |
1048 |
line = lr. |
|
1051 | line = getline(lr, self.hunk) | |
1049 | self.hunk.append(line) |
|
|||
1050 | while len(line) > 1: |
|
1052 | while len(line) > 1: | |
1051 | l = line[0] |
|
1053 | l = line[0] | |
1052 | if l <= 'Z' and l >= 'A': |
|
1054 | if l <= 'Z' and l >= 'A': | |
@@ -1054,12 +1056,11 b' class binhunk(object):' | |||||
1054 | else: |
|
1056 | else: | |
1055 | l = ord(l) - ord('a') + 27 |
|
1057 | l = ord(l) - ord('a') + 27 | |
1056 | try: |
|
1058 | try: | |
1057 |
dec.append(base85.b85decode(line[1: |
|
1059 | dec.append(base85.b85decode(line[1:])[:l]) | |
1058 | except ValueError, e: |
|
1060 | except ValueError, e: | |
1059 | raise PatchError(_('could not decode "%s" binary patch: %s') |
|
1061 | raise PatchError(_('could not decode "%s" binary patch: %s') | |
1060 | % (self._fname, str(e))) |
|
1062 | % (self._fname, str(e))) | |
1061 |
line = lr. |
|
1063 | line = getline(lr, self.hunk) | |
1062 | self.hunk.append(line) |
|
|||
1063 | text = zlib.decompress(''.join(dec)) |
|
1064 | text = zlib.decompress(''.join(dec)) | |
1064 | if len(text) != size: |
|
1065 | if len(text) != size: | |
1065 | raise PatchError(_('"%s" length is %d bytes, should be %d') |
|
1066 | raise PatchError(_('"%s" length is %d bytes, should be %d') | |
@@ -1213,7 +1214,7 b' def iterhunks(fp):' | |||||
1213 | yield 'file', (afile, bfile, h, gp and gp.copy() or None) |
|
1214 | yield 'file', (afile, bfile, h, gp and gp.copy() or None) | |
1214 | yield 'hunk', h |
|
1215 | yield 'hunk', h | |
1215 | elif x.startswith('diff --git'): |
|
1216 | elif x.startswith('diff --git'): | |
1216 | m = gitre.match(x) |
|
1217 | m = gitre.match(x.rstrip(' \r\n')) | |
1217 | if not m: |
|
1218 | if not m: | |
1218 | continue |
|
1219 | continue | |
1219 | if gitpatches is None: |
|
1220 | if gitpatches is None: |
@@ -412,6 +412,27 b' Invalid base85 content' | |||||
412 | abort: could not extract "binary2" binary data |
|
412 | abort: could not extract "binary2" binary data | |
413 | [255] |
|
413 | [255] | |
414 |
|
414 | |||
|
415 | Simulate a copy/paste turning LF into CRLF (issue2870) | |||
|
416 | ||||
|
417 | $ hg revert -aq | |||
|
418 | $ cat > binary.diff <<"EOF" | |||
|
419 | > diff --git a/text2 b/binary2 | |||
|
420 | > rename from text2 | |||
|
421 | > rename to binary2 | |||
|
422 | > index 78981922613b2afb6025042ff6bd878ac1994e85..10efcb362e9f3b3420fcfbfc0e37f3dc16e29757 | |||
|
423 | > GIT binary patch | |||
|
424 | > literal 5 | |||
|
425 | > Mc$`b*O5$Pw00T?_*Z=?k | |||
|
426 | > | |||
|
427 | > EOF | |||
|
428 | >>> fp = file('binary.diff', 'rb') | |||
|
429 | >>> data = fp.read() | |||
|
430 | >>> fp.close() | |||
|
431 | >>> file('binary.diff', 'wb').write(data.replace('\n', '\r\n')) | |||
|
432 | $ rm binary2 | |||
|
433 | $ hg import --no-commit binary.diff | |||
|
434 | applying binary.diff | |||
|
435 | ||||
415 | $ cd .. |
|
436 | $ cd .. | |
416 |
|
437 | |||
417 | Consecutive import with renames (issue2459) |
|
438 | Consecutive import with renames (issue2459) |
General Comments 0
You need to be logged in to leave comments.
Login now