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

Unified Diff: gclient_utils.py

Issue 134313007: Depot tools: use the clang-format binaries that are now included (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fixed gclient_utils_test.py Created 6 years, 11 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
« no previous file with comments | « clang_format.py ('k') | git_cl.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_utils.py
diff --git a/gclient_utils.py b/gclient_utils.py
index 0d5714acc00ac5f67407f6ff30dd46c37cc8fabb..cad181e786b832f1ae56b7b5755a8547e1da50c2 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -33,6 +33,7 @@ class Error(Exception):
msg = '\n'.join('%d> %s' % (index, l) for l in msg.splitlines())
super(Error, self).__init__(msg, *args, **kwargs)
+
def SplitUrlRevision(url):
"""Splits url and returns a two-tuple: url, rev"""
if url.startswith('ssh:'):
@@ -103,10 +104,10 @@ def FileWrite(filename, content, mode='w'):
def safe_rename(old, new):
"""Renames a file reliably.
- Sometimes os.rename does not work because a dying git process keeps a handle
- on it for a few seconds. An exception is then thrown, which make the program
+ Sometimes os.rename does not work because a dying git process keeps a handle
+ on it for a few seconds. An exception is then thrown, which make the program
give up what it was doing and remove what was deleted.
- The only solution is to catch the exception and try again until it works.
+ The only solution is to catch the exception and try again until it works.
"""
# roughly 10s
retries = 100
@@ -560,6 +561,24 @@ def FindFileUpwards(filename, path=None):
path = new_path
+def GetMacWinOrLinux():
+ """Returns 'mac', 'win', or 'linux', matching the current platform."""
+ if sys.platform.startswith(('cygwin', 'win')):
+ return 'win'
+ elif sys.platform.startswith('linux'):
+ return 'linux'
+ elif sys.platform == 'darwin':
+ return 'mac'
+ raise Error('Unknown platform: ' + sys.platform)
+
+
+def GetExeSuffix():
+ """Returns '' or '.exe' depending on how executables work on this platform."""
+ if sys.platform.startswith(('cygwin', 'win')):
+ return '.exe'
+ return ''
+
+
def GetGClientRootAndEntries(path=None):
"""Returns the gclient root and the dict of entries."""
config_file = '.gclient_entries'
« no previous file with comments | « clang_format.py ('k') | git_cl.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698