hgext/fix.py
changeset 38967 a009589cd32a
parent 38950 35bc4b6e132d
child 39826 c31ce080eb75
equal deleted inserted replaced
38966:5b04b6204931 38967:a009589cd32a
   433 
   433 
   434     Returns the file content that results from applying the fixers in some order
   434     Returns the file content that results from applying the fixers in some order
   435     starting with the file's content in the fixctx. Fixers that support line
   435     starting with the file's content in the fixctx. Fixers that support line
   436     ranges will affect lines that have changed relative to any of the basectxs
   436     ranges will affect lines that have changed relative to any of the basectxs
   437     (i.e. they will only avoid lines that are common to all basectxs).
   437     (i.e. they will only avoid lines that are common to all basectxs).
       
   438 
       
   439     A fixer tool's stdout will become the file's new content if and only if it
       
   440     exits with code zero.
   438     """
   441     """
   439     newdata = fixctx[path].data()
   442     newdata = fixctx[path].data()
   440     for fixername, fixer in fixers.iteritems():
   443     for fixername, fixer in fixers.iteritems():
   441         if fixer.affects(opts, fixctx, path):
   444         if fixer.affects(opts, fixctx, path):
   442             rangesfn = lambda: lineranges(opts, path, basectxs, fixctx, newdata)
   445             rangesfn = lambda: lineranges(opts, path, basectxs, fixctx, newdata)
   452                 stdout=subprocess.PIPE,
   455                 stdout=subprocess.PIPE,
   453                 stderr=subprocess.PIPE)
   456                 stderr=subprocess.PIPE)
   454             newerdata, stderr = proc.communicate(newdata)
   457             newerdata, stderr = proc.communicate(newdata)
   455             if stderr:
   458             if stderr:
   456                 showstderr(ui, fixctx.rev(), fixername, stderr)
   459                 showstderr(ui, fixctx.rev(), fixername, stderr)
   457             else:
   460             if proc.returncode == 0:
   458                 newdata = newerdata
   461                 newdata = newerdata
       
   462             elif not stderr:
       
   463                 showstderr(ui, fixctx.rev(), fixername,
       
   464                            _('exited with status %d\n') % (proc.returncode,))
   459     return newdata
   465     return newdata
   460 
   466 
   461 def showstderr(ui, rev, fixername, stderr):
   467 def showstderr(ui, rev, fixername, stderr):
   462     """Writes the lines of the stderr string as warnings on the ui
   468     """Writes the lines of the stderr string as warnings on the ui
   463 
   469