mercurial/patch.py
changeset 13700 63307feb59dd
parent 13699 d3c0e0033f13
child 13701 bc38ff7cb919
equal deleted inserted replaced
13699:d3c0e0033f13 13700:63307feb59dd
   486         if len(cand) > 1:
   486         if len(cand) > 1:
   487             # resort our list of potentials forward then back.
   487             # resort our list of potentials forward then back.
   488             cand.sort(key=lambda x: abs(x - linenum))
   488             cand.sort(key=lambda x: abs(x - linenum))
   489         return cand
   489         return cand
   490 
   490 
   491     def hashlines(self):
       
   492         self.hash = {}
       
   493         for x, s in enumerate(self.lines):
       
   494             self.hash.setdefault(s, []).append(x)
       
   495 
       
   496     def makerejlines(self, fname):
   491     def makerejlines(self, fname):
   497         base = os.path.basename(fname)
   492         base = os.path.basename(fname)
   498         yield "--- %s\n+++ %s\n" % (base, base)
   493         yield "--- %s\n+++ %s\n" % (base, base)
   499         for x in self.rej:
   494         for x in self.rej:
   500             for l in x.hunk:
   495             for l in x.hunk:
   572                 self.lines[start : start + h.lena] = h.new()
   567                 self.lines[start : start + h.lena] = h.new()
   573                 self.offset += h.lenb - h.lena
   568                 self.offset += h.lenb - h.lena
   574                 self.dirty = 1
   569                 self.dirty = 1
   575             return 0
   570             return 0
   576 
   571 
   577         # ok, we couldn't match the hunk.  Lets look for offsets and fuzz it
   572         # ok, we couldn't match the hunk. Lets look for offsets and fuzz it
   578         self.hashlines()
   573         self.hash = {}
       
   574         for x, s in enumerate(self.lines):
       
   575             self.hash.setdefault(s, []).append(x)
   579         if h.hunk[-1][0] != ' ':
   576         if h.hunk[-1][0] != ' ':
   580             # if the hunk tried to put something at the bottom of the file
   577             # if the hunk tried to put something at the bottom of the file
   581             # override the start line and use eof here
   578             # override the start line and use eof here
   582             search_start = len(self.lines)
   579             search_start = len(self.lines)
   583         else:
   580         else: