comparison mercurial/patch.py @ 11376:ad764a6a2eed

patch: inline small, single-use 'close' function
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Thu, 17 Jun 2010 15:50:35 +0200
parents a1aad8333864
children 9916263d9a60
comparison
equal deleted inserted replaced
11375:0f33abfccaa1 11376:ad764a6a2eed
531 if not self.dirty: 531 if not self.dirty:
532 return 532 return
533 if not dest: 533 if not dest:
534 dest = self.fname 534 dest = self.fname
535 self.writelines(dest, self.lines) 535 self.writelines(dest, self.lines)
536
537 def close(self):
538 self.write()
539 self.write_rej()
540 536
541 def apply(self, h): 537 def apply(self, h):
542 if not h.complete(): 538 if not h.complete():
543 raise PatchError(_("bad hunk #%d %s (%d %d %d %d)") % 539 raise PatchError(_("bad hunk #%d %s (%d %d %d %d)") %
544 (h.number, h.desc, len(h.a), h.lena, len(h.b), 540 (h.number, h.desc, len(h.a), h.lena, len(h.b),
1157 opener = util.opener(cwd) 1153 opener = util.opener(cwd)
1158 1154
1159 def closefile(): 1155 def closefile():
1160 if not current_file: 1156 if not current_file:
1161 return 0 1157 return 0
1162 current_file.close() 1158 current_file.write()
1159 current_file.write_rej()
1163 return len(current_file.rej) 1160 return len(current_file.rej)
1164 1161
1165 for state, values in iterhunks(ui, fp, sourcefile): 1162 for state, values in iterhunks(ui, fp, sourcefile):
1166 if state == 'hunk': 1163 if state == 'hunk':
1167 if not current_file: 1164 if not current_file: