Fix patch creation in merge-to-branch script.
authormachenbach@chromium.org <machenbach@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 26 Feb 2014 16:12:32 +0000 (16:12 +0000)
committermachenbach@chromium.org <machenbach@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 26 Feb 2014 16:12:32 +0000 (16:12 +0000)
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

tools/push-to-trunk/git_recipes.py
tools/push-to-trunk/merge_to_branch.py
tools/push-to-trunk/test_scripts.py

index f5a2315..088ba53 100644 (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)]))
index 5f2e573..7e0e51f 100755 (executable)
@@ -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:
index 8e47d46..2cc08ba 100644 (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\"", ""],