Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1104)

Unified Diff: git_wktry.py

Issue 12226013: Add a git command for running ToT WebKit patches against the trybots. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « git-wktry ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_wktry.py
===================================================================
--- git_wktry.py (revision 0)
+++ git_wktry.py (revision 0)
@@ -0,0 +1,86 @@
+#!/usr/bin/python
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+"""Wrapper for trychange.py for WebKit changes."""
+
+import errno
+import logging
+import os
+import sys
+import tempfile
+
+import git_cl
+from scm import GIT
+import trychange
+
+
+class ScopedTemporaryFile(object):
+ def __init__(self, **kwargs):
+ file_handle, self._path = tempfile.mkstemp(**kwargs)
+ os.close(file_handle)
+
+ def __enter__(self):
+ return self._path
+
+ def __exit__(self, type, value, traceback):
+ try:
+ os.remove(self._path)
+ except OSError, e:
+ if e.errno != errno.ENOENT:
+ raise e
+
+
+def generateDiff(path_to_write, chromium_src_root):
+ """Create the diff file to send to the try server. We prepend the WebKit
+ revision to the beginning of the diff so we can patch against ToT or other
+ versions of WebKit."""
+ diff_lines = ['third_party/WebKit@HEAD\n']
+
+ raw_diff = GIT.GenerateDiff(os.path.join(chromium_src_root,
+ 'third_party/WebKit'), full_move=True).splitlines(True)
+ diff_lines.extend(trychange.GetMungedDiff('third_party/WebKit',
+ raw_diff)[0])
+
+ open(path_to_write, 'wb').write(''.join(diff_lines))
+
+
+def addLayoutBotsIfNeeded(argv):
+ for flag in argv:
+ if flag == '--bot' or flag.startswith('--bot=') or flag.startswith('-b'):
+ return argv
+ argv.extend(('--bot', 'linux_layout_rel,mac_layout_rel,win_layout_rel'))
+
+
+def chromiumSrcRoot():
+ root = GIT.GetCheckoutRoot('.')
+ parent_path, leaf_path = os.path.split(root)
+ if leaf_path == 'WebKit':
+ root = GIT.GetCheckoutRoot(parent_path)
+ return root
+
+
+def main(argv):
+ chromium_src_root = chromiumSrcRoot()
+ os.chdir(chromium_src_root)
+ argv = argv[1:]
+ addLayoutBotsIfNeeded(argv)
+
+ with ScopedTemporaryFile() as diff_file:
+ generateDiff(diff_file, chromium_src_root)
+ args = [
+ '--sub_rep', 'third_party/WebKit',
+ '--root', 'src',
+ '--rietveld_url', 'https://codereview.chromium.org',
+ '--diff', diff_file,
+ ]
+ args.extend(argv)
+ cl = git_cl.Changelist()
+ change = cl.GetChange(cl.GetUpstreamBranch(), None)
+ logging.getLogger().handlers = []
+ return trychange.TryChange(args, change,
+ swallow_exception=False, prog='git wktry')
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
Property changes on: git_wktry.py
___________________________________________________________________
Added: svn:eol-style
+ LF
Added: svn:executable
+ *
« no previous file with comments | « git-wktry ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698