[PATCH 4 of 6] patch.makepatchmeta: accept a prefix parameter
Siddharth Agarwal
sid0 at fb.com
Sat Mar 7 02:44:46 CST 2015
# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1425709166 28800
# Fri Mar 06 22:19:26 2015 -0800
# Node ID 0f2dd88434154fe249607ebe51f6e9a933b38768
# Parent 3feae5432bdf844236f7557ec7f10767bd8d4059
patch.makepatchmeta: accept a prefix parameter
This is preparation for upcoming patches that will add support for applying a
patch within a subdirectory.
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -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)
More information about the Mercurial-devel
mailing list