Reviewers: Jakob, ulan,

Message:
PTAL

Description:
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

Please review this at https://codereview.chromium.org/181603002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+8, -6 lines):
  M tools/push-to-trunk/git_recipes.py
  M tools/push-to-trunk/merge_to_branch.py
  M tools/push-to-trunk/test_scripts.py


Index: tools/push-to-trunk/git_recipes.py
diff --git a/tools/push-to-trunk/git_recipes.py b/tools/push-to-trunk/git_recipes.py index f5a231599e255d00675e7b926a45ec33a9ed1053..088ba53bd806bdbae83e52590b44962493854b4c 100644
--- a/tools/push-to-trunk/git_recipes.py
+++ b/tools/push-to-trunk/git_recipes.py
@@ -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: tools/push-to-trunk/merge_to_branch.py
diff --git a/tools/push-to-trunk/merge_to_branch.py b/tools/push-to-trunk/merge_to_branch.py index 5f2e573bdc4e40c3bb924d3abfec21f497dd74ed..7e0e51f982c7b5e247a09e31e09d6a0ad385d36f 100755
--- a/tools/push-to-trunk/merge_to_branch.py
+++ b/tools/push-to-trunk/merge_to_branch.py
@@ -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: tools/push-to-trunk/test_scripts.py
diff --git a/tools/push-to-trunk/test_scripts.py b/tools/push-to-trunk/test_scripts.py index 8e47d468a9f196654d3c400d3a6af836da2eb497..2cc08bacb015ec6f6ffdebb1e7fdce3104d36d41 100644
--- a/tools/push-to-trunk/test_scripts.py
+++ b/tools/push-to-trunk/test_scripts.py
@@ -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 \"[email protected]\"", ""],


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to