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

Side by Side Diff: scm.py

Issue 6674059: Make sure warnings fail the check when may_prompt=False. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: moved determine_scm() Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """SCM-specific utility classes.""" 5 """SCM-specific utility classes."""
6 6
7 import cStringIO 7 import cStringIO
8 import glob 8 import glob
9 import logging 9 import logging
10 import os 10 import os
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 data.write("@@ -0,0 +1,%d @@\n" % nb_lines) 58 data.write("@@ -0,0 +1,%d @@\n" % nb_lines)
59 # Prepend '+' to every lines. 59 # Prepend '+' to every lines.
60 for line in file_content: 60 for line in file_content:
61 data.write('+') 61 data.write('+')
62 data.write(line) 62 data.write(line)
63 result = data.getvalue() 63 result = data.getvalue()
64 data.close() 64 data.close()
65 return result 65 return result
66 66
67 67
68 def determine_scm(root):
69 """Similar to upload.py's version but much simpler.
70
71 Returns 'svn', 'git' or None.
72 """
73 if os.path.isdir(os.path.join(root, '.svn')):
74 return 'svn'
75 elif os.path.isdir(os.path.join(root, '.svn')):
76 return 'git'
77 else:
78 if (0 == subprocess.call(
79 ['git', 'rev-parse', '--show-cdup'],
80 stdout=subprocess.PIPE, cwd=root)):
81 return 'git'
82 else:
83 return None
84
85
68 class GIT(object): 86 class GIT(object):
69 @staticmethod 87 @staticmethod
70 def Capture(args, **kwargs): 88 def Capture(args, **kwargs):
71 return gclient_utils.CheckCall(['git'] + args, print_error=False, 89 return gclient_utils.CheckCall(['git'] + args, print_error=False,
72 **kwargs)[0] 90 **kwargs)[0]
73 91
74 @staticmethod 92 @staticmethod
75 def CaptureStatus(files, upstream_branch=None): 93 def CaptureStatus(files, upstream_branch=None):
76 """Returns git status. 94 """Returns git status.
77 95
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 if (file_status[0][0] in ('D', 'A', '!') or 911 if (file_status[0][0] in ('D', 'A', '!') or
894 not file_status[0][1:].isspace()): 912 not file_status[0][1:].isspace()):
895 # Added, deleted file requires manual intervention and require calling 913 # Added, deleted file requires manual intervention and require calling
896 # revert, like for properties. 914 # revert, like for properties.
897 try: 915 try:
898 SVN.Capture(['revert', file_status[1]], cwd=repo_root) 916 SVN.Capture(['revert', file_status[1]], cwd=repo_root)
899 except gclient_utils.CheckCallError: 917 except gclient_utils.CheckCallError:
900 if not os.path.exists(file_path): 918 if not os.path.exists(file_path):
901 continue 919 continue
902 raise 920 raise
OLDNEW
« presubmit_support.py ('K') | « presubmit_support.py ('k') | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698