Mercurial > hg
changeset 24245:740a17f885a1
patch.makepatchmeta: accept a prefix parameter
This is preparation for upcoming patches that will add support for applying a
patch within a subdirectory.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 06 Mar 2015 22:19:26 -0800 |
parents | 5918bb365c72 |
children | 394a91cb3d4a |
files | mercurial/patch.py |
diffstat | 1 files changed, 6 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py Fri Mar 06 22:17:24 2015 -0800 +++ b/mercurial/patch.py Fri Mar 06 22:19:26 2015 -0800 @@ -1123,14 +1123,14 @@ count -= 1 return path[:i].lstrip(), prefix + path[i:].rstrip() -def makepatchmeta(backend, afile_orig, bfile_orig, hunk, strip): +def makepatchmeta(backend, afile_orig, bfile_orig, hunk, strip, prefix): nulla = afile_orig == "/dev/null" nullb = bfile_orig == "/dev/null" create = nulla and hunk.starta == 0 and hunk.lena == 0 remove = nullb and hunk.startb == 0 and hunk.lenb == 0 - abase, afile = pathtransform(afile_orig, strip, '') + abase, afile = pathtransform(afile_orig, strip, prefix) gooda = not nulla and backend.exists(afile) - bbase, bfile = pathtransform(bfile_orig, strip, '') + bbase, bfile = pathtransform(bfile_orig, strip, prefix) if afile == bfile: goodb = gooda else: @@ -1393,7 +1393,7 @@ if gp.oldpath: gp.oldpath = pstrip(gp.oldpath) else: - gp = makepatchmeta(backend, afile, bfile, first_hunk, strip) + gp = makepatchmeta(backend, afile, bfile, first_hunk, strip, '') if gp.op == 'RENAME': backend.unlink(gp.oldpath) if not first_hunk: @@ -1563,7 +1563,8 @@ if gp.oldpath: gp.oldpath = pathtransform(gp.oldpath, strip - 1, '')[1] else: - gp = makepatchmeta(backend, afile, bfile, first_hunk, strip) + gp = makepatchmeta(backend, afile, bfile, first_hunk, strip, + '') changed.add(gp.path) if gp.op == 'RENAME': changed.add(gp.oldpath)