mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
[scm] Clean up unused functions
This change removes some dead code from back in the SVN days. `GetCasedPath()`[1] and `GenFakeDiff()`[2] were a part of the SVN class from when scm.py used to support two scm. `only_int()` was used within `AssertVersion()` which was removed[3]. I could not find any usage for `ValidateEmail()` even within the old commits[4]. [1] https://codereview.chromium.org/538009 [2] https://codereview.chromium.org/1965001 [3] https://crrev.com/c/2116938 [4] https://codereview.chromium.org/501166 Bug: 1475776 Change-Id: I730f0d994d8027bd67587fd16ad1e502bdfb94fe Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5279813 Reviewed-by: Josip Sokcevic <sokcevic@chromium.org> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
This commit is contained in:
committed by
LUCI CQ
parent
9f9bab25da
commit
6c92a665e1
57
scm.py
57
scm.py
@@ -4,12 +4,9 @@
|
||||
"""SCM-specific utility classes."""
|
||||
|
||||
from collections import defaultdict
|
||||
import glob
|
||||
import io
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import sys
|
||||
from typing import Mapping, List
|
||||
|
||||
import gclient_utils
|
||||
@@ -24,53 +21,6 @@ VERSIONED_DIR = 1
|
||||
VERSIONED_SUBMODULE = 2
|
||||
|
||||
|
||||
def ValidateEmail(email):
|
||||
return (re.match(r"^[a-zA-Z0-9._%\-+]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}$",
|
||||
email) is not None)
|
||||
|
||||
|
||||
def GetCasedPath(path):
|
||||
"""Elcheapos way to get the real path case on Windows."""
|
||||
if sys.platform.startswith('win') and os.path.exists(path):
|
||||
# Reconstruct the path.
|
||||
path = os.path.abspath(path)
|
||||
paths = path.split('\\')
|
||||
for i in range(len(paths)):
|
||||
if i == 0:
|
||||
# Skip drive letter.
|
||||
continue
|
||||
subpath = '\\'.join(paths[:i + 1])
|
||||
prev = len('\\'.join(paths[:i]))
|
||||
# glob.glob will return the cased path for the last item only. This
|
||||
# is why we are calling it in a loop. Extract the data we want and
|
||||
# put it back into the list.
|
||||
paths[i] = glob.glob(subpath + '*')[0][prev + 1:len(subpath)]
|
||||
path = '\\'.join(paths)
|
||||
return path
|
||||
|
||||
|
||||
def GenFakeDiff(filename):
|
||||
"""Generates a fake diff from a file."""
|
||||
file_content = gclient_utils.FileRead(filename, 'rb').splitlines(True)
|
||||
filename = filename.replace(os.sep, '/')
|
||||
nb_lines = len(file_content)
|
||||
# We need to use / since patch on unix will fail otherwise.
|
||||
data = io.StringIO()
|
||||
data.write("Index: %s\n" % filename)
|
||||
data.write('=' * 67 + '\n')
|
||||
# Note: Should we use /dev/null instead?
|
||||
data.write("--- %s\n" % filename)
|
||||
data.write("+++ %s\n" % filename)
|
||||
data.write("@@ -0,0 +1,%d @@\n" % nb_lines)
|
||||
# Prepend '+' to every lines.
|
||||
for line in file_content:
|
||||
data.write('+')
|
||||
data.write(line)
|
||||
result = data.getvalue()
|
||||
data.close()
|
||||
return result
|
||||
|
||||
|
||||
def determine_scm(root):
|
||||
"""Similar to upload.py's version but much simpler.
|
||||
|
||||
@@ -89,13 +39,6 @@ def determine_scm(root):
|
||||
return None
|
||||
|
||||
|
||||
def only_int(val):
|
||||
if val.isdigit():
|
||||
return int(val)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
class GIT(object):
|
||||
current_version = None
|
||||
rev_parse_cache = {}
|
||||
|
||||
Reference in New Issue
Block a user