From 6c92a665e180982ca3ed0ad4a9f0738b119e49a9 Mon Sep 17 00:00:00 2001 From: Aravind Vasudevan Date: Mon, 12 Feb 2024 17:43:39 +0000 Subject: [PATCH] [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 Commit-Queue: Aravind Vasudevan --- scm.py | 57 --------------------------------------------------------- 1 file changed, 57 deletions(-) diff --git a/scm.py b/scm.py index 5062322dc..f2e631106 100644 --- a/scm.py +++ b/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 = {}