##// END OF EJS Templates
patch: remove the unused, broken reverse() function
Nicolas Dumazet -
r9393:23c4e772 default
parent child Browse files
Show More
@@ -378,15 +378,13 b' class patchfile(object):'
378 378 self.write()
379 379 self.write_rej()
380 380
381 def apply(self, h, reverse):
381 def apply(self, h):
382 382 if not h.complete():
383 383 raise PatchError(_("bad hunk #%d %s (%d %d %d %d)") %
384 384 (h.number, h.desc, len(h.a), h.lena, len(h.b),
385 385 h.lenb))
386 386
387 387 self.hunks += 1
388 if reverse:
389 h.reverse()
390 388
391 389 if self.missing:
392 390 self.rej.append(h)
@@ -600,31 +598,6 b' class hunk(object):'
600 598 self.startb, self.lenb)
601 599 self.hunk[0] = self.desc
602 600
603 def reverse(self):
604 self.create, self.remove = self.remove, self.create
605 origlena = self.lena
606 origstarta = self.starta
607 self.lena = self.lenb
608 self.starta = self.startb
609 self.lenb = origlena
610 self.startb = origstarta
611 self.a = []
612 self.b = []
613 # self.hunk[0] is the @@ description
614 for x in xrange(1, len(self.hunk)):
615 o = self.hunk[x]
616 if o.startswith('-'):
617 n = '+' + o[1:]
618 self.b.append(o[1:])
619 elif o.startswith('+'):
620 n = '-' + o[1:]
621 self.a.append(n)
622 else:
623 n = o
624 self.b.append(o[1:])
625 self.a.append(o)
626 self.hunk[x] = o
627
628 601 def fix_newline(self):
629 602 diffhelpers.fix_newline(self.hunk, self.a, self.b)
630 603
@@ -762,7 +735,7 b' def parsefilename(str):'
762 735 return s
763 736 return s[:i]
764 737
765 def selectfile(afile_orig, bfile_orig, hunk, strip, reverse):
738 def selectfile(afile_orig, bfile_orig, hunk, strip):
766 739 def pathstrip(path, count=1):
767 740 pathlen = len(path)
768 741 i = 0
@@ -790,8 +763,6 b' def selectfile(afile_orig, bfile_orig, h'
790 763 else:
791 764 goodb = not nullb and os.path.exists(bfile)
792 765 createfunc = hunk.createfile
793 if reverse:
794 createfunc = hunk.rmfile
795 766 missing = not goodb and not gooda and not createfunc()
796 767
797 768 # some diff programs apparently produce create patches where the
@@ -977,8 +948,7 b' def iterhunks(ui, fp, sourcefile=None, t'
977 948 if hunknum == 0 and dopatch and not gitworkdone:
978 949 raise NoHunks
979 950
980 def applydiff(ui, fp, changed, strip=1, sourcefile=None, reverse=False,
981 eol=None):
951 def applydiff(ui, fp, changed, strip=1, sourcefile=None, eol=None):
982 952 """
983 953 Reads a patch from fp and tries to apply it.
984 954
@@ -1008,7 +978,7 b' def applydiff(ui, fp, changed, strip=1, '
1008 978 if not current_file:
1009 979 continue
1010 980 current_hunk = values
1011 ret = current_file.apply(current_hunk, reverse)
981 ret = current_file.apply(current_hunk)
1012 982 if ret >= 0:
1013 983 changed.setdefault(current_file.fname, None)
1014 984 if ret > 0:
@@ -1021,7 +991,7 b' def applydiff(ui, fp, changed, strip=1, '
1021 991 current_file = patchfile(ui, sourcefile, opener, eol=eol)
1022 992 else:
1023 993 current_file, missing = selectfile(afile, bfile, first_hunk,
1024 strip, reverse)
994 strip)
1025 995 current_file = patchfile(ui, current_file, opener, missing, eol)
1026 996 except PatchError, err:
1027 997 ui.warn(str(err) + '\n')
General Comments 0
You need to be logged in to leave comments. Login now