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

Side by Side Diff: third_party/upload.py

Issue 1544813002: Fix git cl upload deadlock. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Other quotation marks. Created 5 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 # 3 #
4 # Copyright 2007 Google Inc. 4 # Copyright 2007 Google Inc.
5 # 5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License. 7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at 8 # You may obtain a copy of the License at
9 # 9 #
10 # http://www.apache.org/licenses/LICENSE-2.0 10 # http://www.apache.org/licenses/LICENSE-2.0
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 Returns: 856 Returns:
857 Tuple (stdout, stderr, return code) 857 Tuple (stdout, stderr, return code)
858 """ 858 """
859 LOGGER.info("Running %s", command) 859 LOGGER.info("Running %s", command)
860 env = env.copy() 860 env = env.copy()
861 env['LC_MESSAGES'] = 'C' 861 env['LC_MESSAGES'] = 'C'
862 p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, 862 p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
863 shell=use_shell, universal_newlines=universal_newlines, 863 shell=use_shell, universal_newlines=universal_newlines,
864 env=env) 864 env=env)
865 if print_output: 865 if print_output:
866 # It's very hard to stream both stdout and stderr at the same time
867 # without the potential for deadlocks. We will hope for the best
tandrii(chromium) 2015/12/22 14:49:37 indeed, hard. we have a subprocess2 module for thi
868 # since this code path is rarely used.
866 output_array = [] 869 output_array = []
867 while True: 870 while True:
868 line = p.stdout.readline() 871 line = p.stdout.readline()
869 if not line: 872 if not line:
870 break 873 break
871 print line.strip("\n") 874 print line.strip("\n")
872 output_array.append(line) 875 output_array.append(line)
873 output = "".join(output_array) 876 output = "".join(output_array)
877 p.wait()
878 errout = p.stderr.read()
879 if errout:
880 print >> sys.stderr, errout
874 else: 881 else:
875 output = p.stdout.read() 882 output, errout = p.communicate()
876 p.wait()
877 errout = p.stderr.read()
878 if print_output and errout:
879 print >> sys.stderr, errout
880 p.stdout.close() 883 p.stdout.close()
881 p.stderr.close() 884 p.stderr.close()
882 return output, errout, p.returncode 885 return output, errout, p.returncode
883 886
884 def RunShellWithReturnCode(command, print_output=False, 887 def RunShellWithReturnCode(command, print_output=False,
885 universal_newlines=True, 888 universal_newlines=True,
886 env=os.environ): 889 env=os.environ):
887 """Run a command and return output from stdout and the return code.""" 890 """Run a command and return output from stdout and the return code."""
888 out, err, retcode = RunShellWithReturnCodeAndStderr(command, print_output, 891 out, err, retcode = RunShellWithReturnCodeAndStderr(command, print_output,
889 universal_newlines, env) 892 universal_newlines, env)
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 extra_args = self.options.revision.split(":", 1) + extra_args 1444 extra_args = self.options.revision.split(":", 1) + extra_args
1442 else: 1445 else:
1443 extra_args = [self.options.revision] + extra_args 1446 extra_args = [self.options.revision] + extra_args
1444 1447
1445 # --no-ext-diff is broken in some versions of Git, so try to work around 1448 # --no-ext-diff is broken in some versions of Git, so try to work around
1446 # this by overriding the environment (but there is still a problem if the 1449 # this by overriding the environment (but there is still a problem if the
1447 # git config key "diff.external" is used). 1450 # git config key "diff.external" is used).
1448 env = os.environ.copy() 1451 env = os.environ.copy()
1449 if "GIT_EXTERNAL_DIFF" in env: 1452 if "GIT_EXTERNAL_DIFF" in env:
1450 del env["GIT_EXTERNAL_DIFF"] 1453 del env["GIT_EXTERNAL_DIFF"]
1454 # 'cat' is a magical git string that disables pagers on all platforms.
1455 env["GIT_PAGER"] = "cat"
1456
1451 # -M/-C will not print the diff for the deleted file when a file is renamed. 1457 # -M/-C will not print the diff for the deleted file when a file is renamed.
1452 # This is confusing because the original file will not be shown on the 1458 # This is confusing because the original file will not be shown on the
1453 # review when a file is renamed. So, get a diff with ONLY deletes, then 1459 # review when a file is renamed. So, get a diff with ONLY deletes, then
1454 # append a diff (with rename detection), without deletes. 1460 # append a diff (with rename detection), without deletes.
1455 cmd = [ 1461 cmd = [
1456 "git", "diff", "--no-color", "--no-ext-diff", "--full-index", 1462 "git", "diff", "--no-color", "--no-ext-diff", "--full-index",
1457 "--ignore-submodules", "--src-prefix=a/", "--dst-prefix=b/", 1463 "--ignore-submodules", "--src-prefix=a/", "--dst-prefix=b/",
1458 ] 1464 ]
1459 diff = RunShell( 1465 diff = RunShell(
1460 cmd + ["--no-renames", "--diff-filter=D"] + extra_args, 1466 cmd + ["--no-renames", "--diff-filter=D"] + extra_args,
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
2549 print 2555 print
2550 StatusUpdate("Interrupted.") 2556 StatusUpdate("Interrupted.")
2551 sys.exit(1) 2557 sys.exit(1)
2552 except auth.AuthenticationError as e: 2558 except auth.AuthenticationError as e:
2553 print >> sys.stderr, e 2559 print >> sys.stderr, e
2554 sys.exit(1) 2560 sys.exit(1)
2555 2561
2556 2562
2557 if __name__ == "__main__": 2563 if __name__ == "__main__":
2558 main() 2564 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698