Show More
@@ -1035,18 +1035,20 b' class binhunk(object):' | |||
|
1035 | 1035 | return [self.text] |
|
1036 | 1036 | |
|
1037 | 1037 | def _read(self, lr): |
|
1038 | line = lr.readline() | |
|
1039 | self.hunk.append(line) | |
|
1038 | def getline(lr, hunk): | |
|
1039 | l = lr.readline() | |
|
1040 | hunk.append(l) | |
|
1041 | return l.rstrip('\r\n') | |
|
1042 | ||
|
1043 | line = getline(lr, self.hunk) | |
|
1040 | 1044 | while line and not line.startswith('literal '): |
|
1041 |
line = lr. |
|
|
1042 | self.hunk.append(line) | |
|
1045 | line = getline(lr, self.hunk) | |
|
1043 | 1046 | if not line: |
|
1044 | 1047 | raise PatchError(_('could not extract "%s" binary data') |
|
1045 | 1048 | % self._fname) |
|
1046 | 1049 | size = int(line[8:].rstrip()) |
|
1047 | 1050 | dec = [] |
|
1048 |
line = lr. |
|
|
1049 | self.hunk.append(line) | |
|
1051 | line = getline(lr, self.hunk) | |
|
1050 | 1052 | while len(line) > 1: |
|
1051 | 1053 | l = line[0] |
|
1052 | 1054 | if l <= 'Z' and l >= 'A': |
@@ -1054,12 +1056,11 b' class binhunk(object):' | |||
|
1054 | 1056 | else: |
|
1055 | 1057 | l = ord(l) - ord('a') + 27 |
|
1056 | 1058 | try: |
|
1057 |
dec.append(base85.b85decode(line[1: |
|
|
1059 | dec.append(base85.b85decode(line[1:])[:l]) | |
|
1058 | 1060 | except ValueError, e: |
|
1059 | 1061 | raise PatchError(_('could not decode "%s" binary patch: %s') |
|
1060 | 1062 | % (self._fname, str(e))) |
|
1061 |
line = lr. |
|
|
1062 | self.hunk.append(line) | |
|
1063 | line = getline(lr, self.hunk) | |
|
1063 | 1064 | text = zlib.decompress(''.join(dec)) |
|
1064 | 1065 | if len(text) != size: |
|
1065 | 1066 | raise PatchError(_('"%s" length is %d bytes, should be %d') |
@@ -1213,7 +1214,7 b' def iterhunks(fp):' | |||
|
1213 | 1214 | yield 'file', (afile, bfile, h, gp and gp.copy() or None) |
|
1214 | 1215 | yield 'hunk', h |
|
1215 | 1216 | elif x.startswith('diff --git'): |
|
1216 | m = gitre.match(x) | |
|
1217 | m = gitre.match(x.rstrip(' \r\n')) | |
|
1217 | 1218 | if not m: |
|
1218 | 1219 | continue |
|
1219 | 1220 | if gitpatches is None: |
@@ -412,6 +412,27 b' Invalid base85 content' | |||
|
412 | 412 | abort: could not extract "binary2" binary data |
|
413 | 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 | 436 | $ cd .. |
|
416 | 437 | |
|
417 | 438 | Consecutive import with renames (issue2459) |
General Comments 0
You need to be logged in to leave comments.
Login now