Commit cd958053 authored by tandrii@chromium.org's avatar tandrii@chromium.org

Readability improvement in apply_issue.

R=pgervais@chromium.org
BUG=537417

Review URL: https://codereview.chromium.org/1372133004

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@297015 0039d316-1c4b-4281-b951-d872f2087c98
parent 15af77d5
...@@ -27,9 +27,10 @@ import scm ...@@ -27,9 +27,10 @@ import scm
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) BASE_DIR = os.path.dirname(os.path.abspath(__file__))
RETURN_CODE_ARG_PARSER = 2 # default in python. RETURN_CODE_OK = 0 # any other failure, likely patch apply one.
RETURN_CODE_INFRA_FAILURE = 3 # considered as infra failure. RETURN_CODE_OTHER_FAILURE = 1 # any other failure, likely patch apply one.
RETURN_CODE_OTHERWISE = 1 # any other failure, likely patch apply one. RETURN_CODE_ARGPARSE_FAILURE = 2 # default in python.
RETURN_CODE_INFRA_FAILURE = 3 # considered as infra failure.
class Unbuffered(object): class Unbuffered(object):
...@@ -178,7 +179,7 @@ def main(): ...@@ -178,7 +179,7 @@ def main():
properties = rietveld_obj.get_issue_properties(options.issue, False) properties = rietveld_obj.get_issue_properties(options.issue, False)
except rietveld.upload.ClientLoginError as e: except rietveld.upload.ClientLoginError as e:
print('Accessing the issue requires proper credentials.') print('Accessing the issue requires proper credentials.')
return RETURN_CODE_OTHERWISE return RETURN_CODE_OTHER_FAILURE
except urllib2.URLError: except urllib2.URLError:
logging.exception('failed to fetch issue properties') logging.exception('failed to fetch issue properties')
return RETURN_CODE_INFRA_FAILURE return RETURN_CODE_INFRA_FAILURE
...@@ -241,7 +242,7 @@ def main(): ...@@ -241,7 +242,7 @@ def main():
options.server, issue_to_apply) options.server, issue_to_apply)
# If we got this far, then this is likely missing patchset. # If we got this far, then this is likely missing patchset.
# Thus, it's not infra failure. # Thus, it's not infra failure.
return RETURN_CODE_OTHERWISE return RETURN_CODE_OTHER_FAILURE
except urllib2.URLError: except urllib2.URLError:
logging.exception( logging.exception(
'Failed to fetch the patch for issue %d, patchset %d', 'Failed to fetch the patch for issue %d, patchset %d',
...@@ -282,7 +283,7 @@ def main(): ...@@ -282,7 +283,7 @@ def main():
print(str(e)) print(str(e))
print('CWD=%s' % os.getcwd()) print('CWD=%s' % os.getcwd())
print('Checkout path=%s' % scm_obj.project_path) print('Checkout path=%s' % scm_obj.project_path)
return RETURN_CODE_OTHERWISE return RETURN_CODE_OTHER_FAILURE
if ('DEPS' in map(os.path.basename, patchset.filenames) if ('DEPS' in map(os.path.basename, patchset.filenames)
and not options.ignore_deps): and not options.ignore_deps):
...@@ -313,7 +314,7 @@ def main(): ...@@ -313,7 +314,7 @@ def main():
annotated_gclient.emit_buildprops(revisions) annotated_gclient.emit_buildprops(revisions)
return retcode return retcode
return 0 return RETURN_CODE_OK
if __name__ == "__main__": if __name__ == "__main__":
...@@ -322,4 +323,4 @@ if __name__ == "__main__": ...@@ -322,4 +323,4 @@ if __name__ == "__main__":
sys.exit(main()) sys.exit(main())
except KeyboardInterrupt: except KeyboardInterrupt:
sys.stderr.write('interrupted\n') sys.stderr.write('interrupted\n')
sys.exit(RETURN_CODE_OTHERWISE) sys.exit(RETURN_CODE_OTHER_FAILURE)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment