diff -r 5cb459dc32d2 -r 885a573fa619 mercurial/patch.py --- a/mercurial/patch.py Tue Oct 28 22:32:18 2014 -0700 +++ b/mercurial/patch.py Wed Mar 18 20:59:06 2015 -0700 @@ -1465,6 +1465,8 @@ ('', ' a/b/c') >>> pathtransform(' a/b/c ', 2, '') ('a/b/', 'c') + >>> pathtransform('a/b/c', 0, 'd/e/') + ('', 'd/e/a/b/c') >>> pathtransform(' a//b/c ', 2, 'd/e/') ('a//b/', 'd/e/c') >>> pathtransform('a/b/c', 3, '') @@ -1474,7 +1476,7 @@ pathlen = len(path) i = 0 if strip == 0: - return '', path.rstrip() + return '', prefix + path.rstrip() count = strip while count > 0: i = path.find('/', i)