Mercurial > public > mercurial-scm > hg
comparison mercurial/patch.py @ 14255:576256a81cb6
patch: introduce changedfiles
returns the set of all changed files in a given patch
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Fri, 06 May 2011 19:03:41 +0300 |
parents | 28762bb767dc |
children | df9ccd39828c |
comparison
equal
deleted
inserted
replaced
14254:d6a762d93b77 | 14255:576256a81cb6 |
---|---|
1243 if patcher: | 1243 if patcher: |
1244 return _externalpatch(patcher, patchname, ui, strip, cwd, files) | 1244 return _externalpatch(patcher, patchname, ui, strip, cwd, files) |
1245 return internalpatch(patchname, ui, strip, cwd, files, eolmode) | 1245 return internalpatch(patchname, ui, strip, cwd, files, eolmode) |
1246 except PatchError, err: | 1246 except PatchError, err: |
1247 raise util.Abort(str(err)) | 1247 raise util.Abort(str(err)) |
1248 | |
1249 def changedfiles(patchpath, strip=1): | |
1250 fp = open(patchpath, 'rb') | |
1251 try: | |
1252 changed = set() | |
1253 for state, values in iterhunks(fp): | |
1254 if state == 'hunk': | |
1255 continue | |
1256 elif state == 'file': | |
1257 afile, bfile, first_hunk = values | |
1258 current_file, missing = selectfile(afile, bfile, | |
1259 first_hunk, strip) | |
1260 changed.add(current_file) | |
1261 elif state == 'git': | |
1262 for gp in values: | |
1263 gp.path = pathstrip(gp.path, strip - 1)[1] | |
1264 changed.add(gp.path) | |
1265 else: | |
1266 raise util.Abort(_('unsupported parser state: %s') % state) | |
1267 return changed | |
1268 finally: | |
1269 fp.close() | |
1248 | 1270 |
1249 def b85diff(to, tn): | 1271 def b85diff(to, tn): |
1250 '''print base85-encoded binary diff''' | 1272 '''print base85-encoded binary diff''' |
1251 def gitindex(text): | 1273 def gitindex(text): |
1252 if not text: | 1274 if not text: |