Fix patch creation in merge-to-branch script.

Patch white space got stripped, which lead to failures when applying the patch.

- Refine test to reveal the problem
- Create a separate method for retrieving the patch that doesn't strip white space

R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/181603002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19566 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
machenbach@chromium.org 2014-02-26 16:12:32 +00:00
parent 2e01427c3d
commit f09b3db78c
3 changed files with 8 additions and 6 deletions

View File

@ -72,7 +72,7 @@ class GitRecipesMixin(object):
@Strip
def GitLog(self, n=0, format="", grep="", git_hash="", parent_hash="",
branch="", reverse=False, patch=False):
branch="", reverse=False):
assert not (git_hash and parent_hash)
args = ["log"]
if n > 0:
@ -83,8 +83,6 @@ class GitRecipesMixin(object):
args.append("--grep=\"%s\"" % grep)
if reverse:
args.append("--reverse")
if patch:
args.append("-p")
if git_hash:
args.append(git_hash)
if parent_hash:
@ -92,6 +90,10 @@ class GitRecipesMixin(object):
args.append(branch)
return self.Git(MakeArgs(args))
def GitGetPatch(self, git_hash):
assert git_hash
return self.Git(MakeArgs(["log", "-1", "-p", git_hash]))
def GitAdd(self, name):
assert name
self.Git(MakeArgs(["add", Quoted(name)]))

View File

@ -182,7 +182,7 @@ class ApplyPatches(Step):
for commit_hash in self["patch_commit_hashes"]:
print("Applying patch for %s to %s..."
% (commit_hash, self["merge_to_branch"]))
patch = self.GitLog(n=1, patch=True, git_hash=commit_hash)
patch = self.GitGetPatch(commit_hash)
TextToFile(patch, self.Config(TEMPORARY_PATCH_FILE))
self.ApplyPatch(self.Config(TEMPORARY_PATCH_FILE), self._options.revert)
if self._options.patch:

View File

@ -950,9 +950,9 @@ LOG=N
["log -1 -p hash1", "patch1"],
["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
"", VerifyPatch("patch1")],
["log -1 -p hash5", "patch5"],
["log -1 -p hash5", "patch5\n"],
["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
"", VerifyPatch("patch5")],
"", VerifyPatch("patch5\n")],
["apply --index --reject \"%s\"" % extra_patch, ""],
["commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], ""],
["cl upload --send-mail -r \"reviewer@chromium.org\"", ""],