mercurial/patch.py
changeset 27796 f7f3958d39c0
parent 27485 60183975b5bc
child 27900 27572a5cc409
equal deleted inserted replaced
27795:3e0d27d298b7 27796:f7f3958d39c0
  2097     return internalpatch(ui, repo, patchname, strip, prefix, files, eolmode,
  2097     return internalpatch(ui, repo, patchname, strip, prefix, files, eolmode,
  2098                          similarity)
  2098                          similarity)
  2099 
  2099 
  2100 def changedfiles(ui, repo, patchpath, strip=1):
  2100 def changedfiles(ui, repo, patchpath, strip=1):
  2101     backend = fsbackend(ui, repo.root)
  2101     backend = fsbackend(ui, repo.root)
  2102     fp = open(patchpath, 'rb')
  2102     with open(patchpath, 'rb') as fp:
  2103     try:
       
  2104         changed = set()
  2103         changed = set()
  2105         for state, values in iterhunks(fp):
  2104         for state, values in iterhunks(fp):
  2106             if state == 'file':
  2105             if state == 'file':
  2107                 afile, bfile, first_hunk, gp = values
  2106                 afile, bfile, first_hunk, gp = values
  2108                 if gp:
  2107                 if gp:
  2116                 if gp.op == 'RENAME':
  2115                 if gp.op == 'RENAME':
  2117                     changed.add(gp.oldpath)
  2116                     changed.add(gp.oldpath)
  2118             elif state not in ('hunk', 'git'):
  2117             elif state not in ('hunk', 'git'):
  2119                 raise error.Abort(_('unsupported parser state: %s') % state)
  2118                 raise error.Abort(_('unsupported parser state: %s') % state)
  2120         return changed
  2119         return changed
  2121     finally:
       
  2122         fp.close()
       
  2123 
  2120 
  2124 class GitDiffRequired(Exception):
  2121 class GitDiffRequired(Exception):
  2125     pass
  2122     pass
  2126 
  2123 
  2127 def diffallopts(ui, opts=None, untrusted=False, section='diff'):
  2124 def diffallopts(ui, opts=None, untrusted=False, section='diff'):