mercurial/patch.py
changeset 41759 aaad36b88298
parent 41646 d4c9eebdd72d
child 41784 251332dbf33d
equal deleted inserted replaced
41758:15d3facfa40a 41759:aaad36b88298
   923         # cannot take some of it.
   923         # cannot take some of it.
   924         # Newly added files are special if they are empty, they are not special
   924         # Newly added files are special if they are empty, they are not special
   925         # if they have some content as we want to be able to change it
   925         # if they have some content as we want to be able to change it
   926         nocontent = len(self.header) == 2
   926         nocontent = len(self.header) == 2
   927         emptynewfile = self.isnewfile() and nocontent
   927         emptynewfile = self.isnewfile() and nocontent
   928         return emptynewfile or \
   928         return (emptynewfile
   929                 any(self.special_re.match(h) for h in self.header)
   929                 or any(self.special_re.match(h) for h in self.header))
   930 
   930 
   931 class recordhunk(object):
   931 class recordhunk(object):
   932     """patch hunk
   932     """patch hunk
   933 
   933 
   934     XXX shouldn't we merge this with the other hunk class?
   934     XXX shouldn't we merge this with the other hunk class?
  2281             copysourcematch=copysourcematch):
  2281             copysourcematch=copysourcematch):
  2282         if hunksfilterfn is not None:
  2282         if hunksfilterfn is not None:
  2283             # If the file has been removed, fctx2 is None; but this should
  2283             # If the file has been removed, fctx2 is None; but this should
  2284             # not occur here since we catch removed files early in
  2284             # not occur here since we catch removed files early in
  2285             # logcmdutil.getlinerangerevs() for 'hg log -L'.
  2285             # logcmdutil.getlinerangerevs() for 'hg log -L'.
  2286             assert fctx2 is not None, \
  2286             assert fctx2 is not None, (
  2287                 'fctx2 unexpectly None in diff hunks filtering'
  2287                 'fctx2 unexpectly None in diff hunks filtering')
  2288             hunks = hunksfilterfn(fctx2, hunks)
  2288             hunks = hunksfilterfn(fctx2, hunks)
  2289         text = ''.join(sum((list(hlines) for hrange, hlines in hunks), []))
  2289         text = ''.join(sum((list(hlines) for hrange, hlines in hunks), []))
  2290         if hdr and (text or len(hdr) > 1):
  2290         if hdr and (text or len(hdr) > 1):
  2291             yield '\n'.join(hdr) + '\n'
  2291             yield '\n'.join(hdr) + '\n'
  2292         if text:
  2292         if text: