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

Unified Diff: git_number.py

Issue 955993006: Handle KeyboardInterrupt consistently in python scripts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: tweek test expectations Created 5 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
Index: git_number.py
diff --git a/git_number.py b/git_number.py
index 6997f51b3d0ffd6a21383949315ff7dbdcd6109d..1867b97d7ca58b68856fa495cd303ca6907bbe10 100755
--- a/git_number.py
+++ b/git_number.py
@@ -259,25 +259,26 @@ def main(): # pragma: no cover
"use the 'Cr-Commit-Position' value in the commit's message.")
return 1
+ if opts.reset:
+ clear_caches(on_disk=True)
+ return
+
try:
- if opts.reset:
- clear_caches(on_disk=True)
- return
+ targets = git.parse_commitrefs(*(args or ['HEAD']))
+ except git.BadCommitRefException as e:
+ parser.error(e)
- try:
- targets = git.parse_commitrefs(*(args or ['HEAD']))
- except git.BadCommitRefException as e:
- parser.error(e)
+ load_generation_numbers(targets)
+ if not opts.no_cache:
+ finalize(targets)
- load_generation_numbers(targets)
- if not opts.no_cache:
- finalize(targets)
-
- print '\n'.join(map(str, map(get_num, targets)))
- return 0
- except KeyboardInterrupt:
- return 1
+ print '\n'.join(map(str, map(get_num, targets)))
+ return 0
if __name__ == '__main__': # pragma: no cover
- sys.exit(main())
+ try:
+ sys.exit(main())
+ except KeyboardInterrupt:
+ sys.stderr.write('interrupted\n')
+ sys.exit(1)
« clang_format.py ('K') | « git_new_branch.py ('k') | git_rebase_update.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698