Move scm.py to lib/
It belongs there.
Change-Id: I286b50c43c587c39557fc508175efbd4b0f51d51
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4289680
Reviewed-by: Joanna Wang <jojwang@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
diff --git a/gclient_utils.py b/gclient_utils.py
index 6a1659d..d16e77b 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -38,6 +38,8 @@
import queue
import urllib.parse as urlparse
+from lib import utils
+
# Git wrapper retries on a transient error, and some callees do retries too,
# such as GitWrapper.update (doing clone). One retry attempt should be
@@ -212,19 +214,14 @@
sys.exit(1)
+# TODO(sokcevic): remove the usage of this
def FileRead(filename, mode='rbU'):
- # mode is ignored now; we always return unicode strings.
- with open(filename, mode='rb') as f:
- s = f.read()
- try:
- return s.decode('utf-8', 'replace')
- except (UnicodeDecodeError, AttributeError):
- return s
+ return utils.FileRead(filename, mode)
+# TODO(sokcevic): remove the usage of this
def FileWrite(filename, content, mode='w', encoding='utf-8'):
- with codecs.open(filename, mode=mode, encoding=encoding) as f:
- f.write(content)
+ return utils.FileWrite(filename, content, mode, encoding)
@contextlib.contextmanager