diff options
author | Mehdi Amini <joker.eph@gmail.com> | 2019-07-30 15:25:14 +0000 |
---|---|---|
committer | Mehdi Amini <joker.eph@gmail.com> | 2019-07-30 15:25:14 +0000 |
commit | c960c0a4915b18592691288c14d2cebd806197a9 (patch) | |
tree | 2dacd840d79bc8ea336896cac8f575eb32d90bf5 | |
parent | 7492b1ea07b0d74f3c5dbb38187477aab21774e8 (diff) | |
download | bcm5719-llvm-c960c0a4915b18592691288c14d2cebd806197a9.tar.gz bcm5719-llvm-c960c0a4915b18592691288c14d2cebd806197a9.zip |
Ask confirmation when `git llvm push` will push multiple commits
This can reduce unexpectedly pushing more than expected by the user.
Differential Revision: https://reviews.llvm.org/D64893
llvm-svn: 367321
-rwxr-xr-x | llvm/utils/git-svn/git-llvm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/utils/git-svn/git-llvm b/llvm/utils/git-svn/git-llvm index d216614de52..f4aa985cbc1 100755 --- a/llvm/utils/git-svn/git-llvm +++ b/llvm/utils/git-svn/git-llvm @@ -27,6 +27,11 @@ import time assert sys.version_info >= (2, 7) try: + exec("import __builtin__") # To avoid IDE's grammar check +except ImportError: + import builtins + +try: dict.iteritems except AttributeError: # Python 3 @@ -99,6 +104,21 @@ def die(msg): sys.exit(1) +def ask_confirm(prompt): + # Python 2/3 compatibility + try: + input = eval("__builtin__.raw_input") + except NameError: + input = builtins.input + + while True: + query = input('%s (y/N): ' % (prompt)) + if query.lower() not in ['y','n', '']: + print('Expect y or n!') + continue + return query.lower() == 'y' + + def split_first_path_component(d): # Assuming we have a git path, it'll use slashes even on windows...I hope. if '/' in d: @@ -427,6 +447,12 @@ def cmd_push(args): 's' if len(revs) != 1 else '', '\n'.join(' ' + git('show', '--oneline', '--quiet', c) for c in revs))) + + # Ask confirmation if multiple commits are about to be pushed + if len(revs) != 1: + if not ask_confirm("Are you sure?"): + die("Aborting") + for r in revs: clean_svn(svn_root) svn_push_one_rev(svn_root, r, git_to_svn_mapping, dry_run) |