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

Unified Diff: gcl.py

Issue 428001: Avoid losing CL description during Rietveld outage.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 11 years, 1 month 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 | « no previous file | tests/gcl_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gcl.py
===================================================================
--- gcl.py (revision 32565)
+++ gcl.py (working copy)
@@ -270,7 +270,8 @@
# _SEPARATOR\n
# description
- def __init__(self, name, issue, patchset, description, files, local_root):
+ def __init__(self, name, issue, patchset, description, files, local_root,
+ needs_upload=False):
self.name = name
self.issue = int(issue)
self.patchset = int(patchset)
@@ -280,7 +281,11 @@
self._files = files
self.patch = None
self._local_root = local_root
+ self.needs_upload = needs_upload
+ def NeedsUpload(self):
+ return self.needs_upload
+
def GetFileNames(self):
"""Returns the list of file names included in this change."""
return [f[1] for f in self._files]
@@ -308,8 +313,12 @@
def Save(self):
"""Writes the changelist information to disk."""
+ if self.NeedsUpload():
+ needs_upload = "dirty"
+ else:
+ needs_upload = "clean"
data = ChangeInfo._SEPARATOR.join([
M-A Ruel 2009/11/22 18:06:10 We should have used json or pickle right at the st
- "%d, %d" % (self.issue, self.patchset),
+ "%d, %d, %s" % (self.issue, self.patchset, needs_upload),
"\n".join([f[0] + f[1] for f in self.GetFiles()]),
self.description])
WriteFile(GetChangelistInfoFile(self.name), data)
@@ -427,17 +436,21 @@
if not os.path.exists(info_file):
if fail_on_not_found:
ErrorExit("Changelist " + changename + " not found.")
- return ChangeInfo(changename, 0, 0, '', None, local_root)
+ return ChangeInfo(changename, 0, 0, '', None, local_root,
+ needs_upload=False)
split_data = ReadFile(info_file).split(ChangeInfo._SEPARATOR, 2)
if len(split_data) != 3:
ErrorExit("Changelist file %s is corrupt" % info_file)
- items = split_data[0].split(',')
+ items = split_data[0].split(', ')
issue = 0
patchset = 0
+ needs_upload = False
if items[0]:
issue = int(items[0])
if len(items) > 1:
patchset = int(items[1])
+ if len(items) > 2:
+ needs_upload = (items[2] == "dirty")
files = []
for line in split_data[1].splitlines():
status = line[:7]
@@ -459,7 +472,7 @@
save = True
files[files.index(item)] = (status, item[1])
change_info = ChangeInfo(changename, issue, patchset, description, files,
- local_root)
+ local_root, needs_upload)
if save:
change_info.Save()
return change_info
@@ -479,7 +492,8 @@
This is mainly usefull to concatenate many changes into one for a 'gcl try'.
"""
changes = changenames.split(',')
- aggregate_change_info = ChangeInfo(changenames, 0, 0, '', None, local_root)
+ aggregate_change_info = ChangeInfo(changenames, 0, 0, '', None, local_root,
+ needs_upload=False)
for change in changes:
aggregate_change_info._files += ChangeInfo.Load(change,
local_root,
@@ -979,7 +993,7 @@
else:
override_description = None
- if change_info.issue:
+ if change_info.issue and not change_info.NeedsUpload():
try:
description = GetIssueDescription(change_info.issue)
except urllib2.HTTPError, err:
@@ -1036,13 +1050,12 @@
if len(split_result) != 2:
ErrorExit("Don't modify the text starting with ---!\n\n" + result)
+ # Update the CL description if it has changed.
new_description = split_result[0]
cl_files_text = split_result[1]
if new_description != description or override_description:
change_info.description = new_description
- if change_info.issue:
- # Update the Rietveld issue with the new description.
- change_info.UpdateRietveldDescription()
+ change_info.needs_upload = True
new_cl_files = []
for line in cl_files_text.splitlines():
@@ -1068,6 +1081,13 @@
if change_info.MissingTests():
Warn("WARNING: " + MISSING_TEST_MSG)
+ # Update the Rietveld issue.
+ if change_info.issue and change_info.NeedsUpload():
+ change_info.UpdateRietveldDescription()
+ change_info.needs_upload = False
+ change_info.Save()
+
+
# Valid extensions for files we want to lint.
DEFAULT_LINT_REGEX = r"(.*\.cpp|.*\.cc|.*\.h)"
DEFAULT_LINT_IGNORE_REGEX = r""
« no previous file with comments | « no previous file | tests/gcl_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698