Mercurial > hg
changeset 9393:23c4e772c172
patch: remove the unused, broken reverse() function
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Sun, 23 Aug 2009 14:32:58 +0200 |
parents | 039bce1b505f |
children | 31203db1b2ac |
files | mercurial/patch.py |
diffstat | 1 files changed, 5 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py Mon Aug 24 14:40:21 2009 +0200 +++ b/mercurial/patch.py Sun Aug 23 14:32:58 2009 +0200 @@ -378,15 +378,13 @@ self.write() self.write_rej() - def apply(self, h, reverse): + def apply(self, h): if not h.complete(): raise PatchError(_("bad hunk #%d %s (%d %d %d %d)") % (h.number, h.desc, len(h.a), h.lena, len(h.b), h.lenb)) self.hunks += 1 - if reverse: - h.reverse() if self.missing: self.rej.append(h) @@ -600,31 +598,6 @@ self.startb, self.lenb) self.hunk[0] = self.desc - def reverse(self): - self.create, self.remove = self.remove, self.create - origlena = self.lena - origstarta = self.starta - self.lena = self.lenb - self.starta = self.startb - self.lenb = origlena - self.startb = origstarta - self.a = [] - self.b = [] - # self.hunk[0] is the @@ description - for x in xrange(1, len(self.hunk)): - o = self.hunk[x] - if o.startswith('-'): - n = '+' + o[1:] - self.b.append(o[1:]) - elif o.startswith('+'): - n = '-' + o[1:] - self.a.append(n) - else: - n = o - self.b.append(o[1:]) - self.a.append(o) - self.hunk[x] = o - def fix_newline(self): diffhelpers.fix_newline(self.hunk, self.a, self.b) @@ -762,7 +735,7 @@ return s return s[:i] -def selectfile(afile_orig, bfile_orig, hunk, strip, reverse): +def selectfile(afile_orig, bfile_orig, hunk, strip): def pathstrip(path, count=1): pathlen = len(path) i = 0 @@ -790,8 +763,6 @@ else: goodb = not nullb and os.path.exists(bfile) createfunc = hunk.createfile - if reverse: - createfunc = hunk.rmfile missing = not goodb and not gooda and not createfunc() # some diff programs apparently produce create patches where the @@ -977,8 +948,7 @@ if hunknum == 0 and dopatch and not gitworkdone: raise NoHunks -def applydiff(ui, fp, changed, strip=1, sourcefile=None, reverse=False, - eol=None): +def applydiff(ui, fp, changed, strip=1, sourcefile=None, eol=None): """ Reads a patch from fp and tries to apply it. @@ -1008,7 +978,7 @@ if not current_file: continue current_hunk = values - ret = current_file.apply(current_hunk, reverse) + ret = current_file.apply(current_hunk) if ret >= 0: changed.setdefault(current_file.fname, None) if ret > 0: @@ -1021,7 +991,7 @@ current_file = patchfile(ui, sourcefile, opener, eol=eol) else: current_file, missing = selectfile(afile, bfile, first_hunk, - strip, reverse) + strip) current_file = patchfile(ui, current_file, opener, missing, eol) except PatchError, err: ui.warn(str(err) + '\n')