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

Unified Diff: trychange.py

Issue 481006: Allow git-try to try rietveld changes directly. (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: Fix comments Created 10 years, 11 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
« git-try ('K') | « tests/trychange_unittest.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trychange.py
===================================================================
--- trychange.py (revision 35878)
+++ trychange.py (working copy)
@@ -393,6 +393,15 @@
"Are you in a working copy directory?")
+def GetMungedDiff(path_diff, diff):
+ # Munge paths to match svn.
+ for i in range(len(diff)):
+ if diff[i].startswith('--- ') or diff[i].startswith('+++ '):
+ new_file = posixpath.join(path_diff, diff[i][4:]).replace('\\', '/')
+ diff[i] = diff[i][0:4] + new_file
+ return diff
+
+
def TryChange(argv,
file_list,
swallow_exception,
@@ -427,6 +436,8 @@
help="Update rietveld issue try job status")
group.add_option("--dry_run", action='store_true',
help="Just prints the diff and quits")
+ group.add_option("--rietveld_url",
+ help="The code review url.")
parser.add_option_group(group)
group = optparse.OptionGroup(parser, "Try job options")
@@ -558,19 +569,27 @@
if options.files:
parser.error('You cannot specify files and --diff at the same time.')
options.diff = gclient_utils.FileRead(options.diff, 'rb')
+ elif options.issue:
+ # Retrieve the patch from rietveld when the diff is not specified.
+ try:
+ import simplejson
+ except ImportError:
+ parser.error('simplejson library is missing, please install.')
+ api_url = 'http://%s/api/%d' % (options.rietveld_url, options.issue)
+ contents = simplejson.loads(urllib.urlopen(api_url).read())
+ diff_url = ('http://%s/download/issue%d_%d.diff' %
Nico 2010/01/10 04:55:49 …then this branch is taken and api_url is http://N
+ (options.rietveld_url, options.issue, contents['patchsets'][-1]))
+ diff = GetMungedDiff('', urllib.urlopen(diff_url).readlines())
Nico 2010/01/10 05:02:44 wait, do i read this right? does this mean that th
+ options.diff = ''.join(diff)
else:
# Use this as the base.
root = checkouts[0].checkout_root
diffs = []
for checkout in checkouts:
diff = checkout.GenerateDiff().splitlines(True)
+ path_diff = gclient_utils.PathDifference(root, checkout.checkout_root)
# Munge it.
- path_diff = gclient_utils.PathDifference(root, checkout.checkout_root)
- for i in range(len(diff)):
- if diff[i].startswith('--- ') or diff[i].startswith('+++ '):
- new_file = posixpath.join(path_diff, diff[i][4:]).replace('\\', '/')
- diff[i] = diff[i][0:4] + new_file
- diffs.extend(diff)
+ diffs.extend(GetMungedDiff(path_diff, diff))
options.diff = ''.join(diffs)
if not options.bot:
« git-try ('K') | « tests/trychange_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698