Show More
@@ -610,6 +610,12 b' class patchfile(object):' | |||||
610 | self.rej.append(horig) |
|
610 | self.rej.append(horig) | |
611 | return -1 |
|
611 | return -1 | |
612 |
|
612 | |||
|
613 | def close(self): | |||
|
614 | if self.dirty: | |||
|
615 | self.writelines(self.fname, self.lines) | |||
|
616 | self.write_rej() | |||
|
617 | return len(self.rej) | |||
|
618 | ||||
613 | class hunk(object): |
|
619 | class hunk(object): | |
614 | def __init__(self, desc, num, lr, context, create=False, remove=False): |
|
620 | def __init__(self, desc, num, lr, context, create=False, remove=False): | |
615 | self.number = num |
|
621 | self.number = num | |
@@ -1107,14 +1113,6 b' def _applydiff(ui, fp, patcher, copyfn, ' | |||||
1107 | cwd = os.getcwd() |
|
1113 | cwd = os.getcwd() | |
1108 | opener = util.opener(cwd) |
|
1114 | opener = util.opener(cwd) | |
1109 |
|
1115 | |||
1110 | def closefile(): |
|
|||
1111 | if not current_file: |
|
|||
1112 | return 0 |
|
|||
1113 | if current_file.dirty: |
|
|||
1114 | current_file.writelines(current_file.fname, current_file.lines) |
|
|||
1115 | current_file.write_rej() |
|
|||
1116 | return len(current_file.rej) |
|
|||
1117 |
|
||||
1118 | for state, values in iterhunks(ui, fp): |
|
1116 | for state, values in iterhunks(ui, fp): | |
1119 | if state == 'hunk': |
|
1117 | if state == 'hunk': | |
1120 | if not current_file: |
|
1118 | if not current_file: | |
@@ -1125,7 +1123,8 b' def _applydiff(ui, fp, patcher, copyfn, ' | |||||
1125 | if ret > 0: |
|
1123 | if ret > 0: | |
1126 | err = 1 |
|
1124 | err = 1 | |
1127 | elif state == 'file': |
|
1125 | elif state == 'file': | |
1128 |
|
|
1126 | if current_file: | |
|
1127 | rejects += current_file.close() | |||
1129 | afile, bfile, first_hunk = values |
|
1128 | afile, bfile, first_hunk = values | |
1130 | try: |
|
1129 | try: | |
1131 | current_file, missing = selectfile(afile, bfile, |
|
1130 | current_file, missing = selectfile(afile, bfile, | |
@@ -1150,7 +1149,8 b' def _applydiff(ui, fp, patcher, copyfn, ' | |||||
1150 | else: |
|
1149 | else: | |
1151 | raise util.Abort(_('unsupported parser state: %s') % state) |
|
1150 | raise util.Abort(_('unsupported parser state: %s') % state) | |
1152 |
|
1151 | |||
1153 | rejects += closefile() |
|
1152 | if current_file: | |
|
1153 | rejects += current_file.close() | |||
1154 |
|
1154 | |||
1155 | if rejects: |
|
1155 | if rejects: | |
1156 | return -1 |
|
1156 | return -1 |
General Comments 0
You need to be logged in to leave comments.
Login now