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

Unified Diff: gcl.py

Issue 391075: Revert 32057, 32058, 32059, 32062 because they still have unwanted side-effects. (Closed)
Patch Set: Created 11 years, 1 month 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 | « no previous file | gclient.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gcl.py
diff --git a/gcl.py b/gcl.py
index 1a9ce9d4957b5bcf6e8c311b6d7b429dc257f14b..16afdd7c4292c01c1cf452f70445f4b05969a44c 100755
--- a/gcl.py
+++ b/gcl.py
@@ -19,10 +19,10 @@ import upload
import urllib2
# gcl now depends on gclient.
-from scm import SVN
+import gclient_scm
import gclient_utils
-__version__ = '1.1.2'
+__version__ = '1.1.1'
CODEREVIEW_SETTINGS = {
@@ -46,13 +46,43 @@ MISSING_TEST_MSG = "Change contains new or modified methods, but no new tests!"
FILES_CACHE = {}
+### SVN Functions
+
+def IsSVNMoved(filename):
+ """Determine if a file has been added through svn mv"""
+ info = gclient_scm.CaptureSVNInfo(filename)
+ return (info.get('Copied From URL') and
+ info.get('Copied From Rev') and
+ info.get('Schedule') == 'add')
+
+
+def GetSVNFileProperty(file, property_name):
+ """Returns the value of an SVN property for the given file.
+
+ Args:
+ file: The file to check
+ property_name: The name of the SVN property, e.g. "svn:mime-type"
+
+ Returns:
+ The value of the property, which will be the empty string if the property
+ is not set on the file. If the file is not under version control, the
+ empty string is also returned.
+ """
+ output = RunShell(["svn", "propget", property_name, file])
+ if (output.startswith("svn: ") and
+ output.endswith("is not under version control")):
+ return ""
+ else:
+ return output
+
+
def UnknownFiles(extra_args):
"""Runs svn status and prints unknown files.
Any args in |extra_args| are passed to the tool to support giving alternate
code locations.
"""
- return [item[1] for item in SVN.CaptureStatus(extra_args)
+ return [item[1] for item in gclient_scm.CaptureSVNStatus(extra_args)
if item[0][0] == '?']
@@ -63,7 +93,7 @@ def GetRepositoryRoot():
"""
global REPOSITORY_ROOT
if not REPOSITORY_ROOT:
- infos = SVN.CaptureInfo(os.getcwd(), print_error=False)
+ infos = gclient_scm.CaptureSVNInfo(os.getcwd(), print_error=False)
cur_dir_repo_root = infos.get("Repository Root")
if not cur_dir_repo_root:
raise gclient_utils.Error("gcl run outside of repository")
@@ -71,7 +101,7 @@ def GetRepositoryRoot():
REPOSITORY_ROOT = os.getcwd()
while True:
parent = os.path.dirname(REPOSITORY_ROOT)
- if (SVN.CaptureInfo(parent, print_error=False).get(
+ if (gclient_scm.CaptureSVNInfo(parent, print_error=False).get(
"Repository Root") != cur_dir_repo_root):
break
REPOSITORY_ROOT = parent
@@ -116,7 +146,7 @@ def GetCachedFile(filename, max_age=60*60*24*3, use_root=False):
os.stat(cached_file).st_mtime > max_age):
local_dir = os.path.dirname(os.path.abspath(filename))
local_base = os.path.basename(filename)
- dir_info = SVN.CaptureInfo(".")
+ dir_info = gclient_scm.CaptureSVNInfo(".")
repo_root = dir_info["Repository Root"]
if use_root:
url_path = repo_root
@@ -128,7 +158,7 @@ def GetCachedFile(filename, max_age=60*60*24*3, use_root=False):
r = ""
if not use_root:
local_path = os.path.join(local_dir, local_base)
- r = SVN.CaptureStatus((local_path,))
+ r = gclient_scm.CaptureSVNStatus((local_path,))
rc = -1
if r:
status = r[0][0]
@@ -448,7 +478,7 @@ class ChangeInfo(object):
if update_status:
for item in files:
filename = os.path.join(local_root, item[1])
- status_result = SVN.CaptureStatus(filename)
+ status_result = gclient_scm.CaptureSVNStatus(filename)
if not status_result or not status_result[0][0]:
# File has been reverted.
save = True
@@ -532,7 +562,7 @@ def GetModifiedFiles():
files_in_cl[filename] = change_info.name
# Get all the modified files.
- status_result = SVN.CaptureStatus(None)
+ status_result = gclient_scm.CaptureSVNStatus(None)
for line in status_result:
status = line[0]
filename = line[1]
@@ -719,10 +749,10 @@ def GenerateDiff(files, root=None):
diff = []
for filename in files:
- # TODO(maruel): Use SVN.DiffItem().
# Use svn info output instead of os.path.isdir because the latter fails
# when the file is deleted.
- if SVN.CaptureInfo(filename).get('Node Kind') == 'directory':
+ if gclient_scm.CaptureSVNInfo(filename).get("Node Kind") in ("dir",
+ "directory"):
continue
# If the user specified a custom diff command in their svn config file,
# then it'll be used when we do svn diff, which we don't want to happen
@@ -740,7 +770,7 @@ def GenerateDiff(files, root=None):
output = RunShell(["svn", "diff", "--config-dir", bogus_dir, filename])
if output:
diff.append(output)
- elif SVN.IsMoved(filename):
+ elif IsSVNMoved(filename):
# svn diff on a mv/cp'd file outputs nothing.
# We put in an empty Index entry so upload.py knows about them.
diff.append("\nIndex: %s\n" % filename)
@@ -966,7 +996,7 @@ def Change(change_info, args):
silent = FilterFlag(args, "--silent")
# Verify the user is running the change command from a read-write checkout.
- svn_info = SVN.CaptureInfo('.')
+ svn_info = gclient_scm.CaptureSVNInfo('.')
if not svn_info:
ErrorExit("Current checkout is unversioned. Please retry with a versioned "
"directory.")
@@ -978,7 +1008,7 @@ def Change(change_info, args):
f.close()
else:
override_description = None
-
+
if change_info.issue:
try:
description = GetIssueDescription(change_info.issue)
« no previous file with comments | « no previous file | gclient.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698