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

Unified Diff: gcl.py

Issue 113290: Deprecate gcl.GetSVNFileInfo() for gclient.CaptureSVNInfo(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: fixed presubmit.py and updated unit tests Created 11 years, 7 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 | « no previous file | presubmit.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gcl.py
===================================================================
--- gcl.py (revision 15890)
+++ gcl.py (working copy)
@@ -18,6 +18,8 @@
import urllib2
import xml.dom.minidom
+# gcl now depends on gclient.
+import gclient
__version__ = '1.0'
@@ -44,61 +46,16 @@
read_gcl_info = False
-### Simplified XML processing functions.
-
-def ParseXML(output):
- try:
- return xml.dom.minidom.parseString(output)
- except xml.parsers.expat.ExpatError:
- return None
-
-def GetNamedNodeText(node, node_name):
- child_nodes = node.getElementsByTagName(node_name)
- if not child_nodes:
- return None
- assert len(child_nodes) == 1 and child_nodes[0].childNodes.length == 1
- return child_nodes[0].firstChild.nodeValue
-
-
-def GetNodeNamedAttributeText(node, node_name, attribute_name):
- child_nodes = node.getElementsByTagName(node_name)
- if not child_nodes:
- return None
- assert len(child_nodes) == 1
- return child_nodes[0].getAttribute(attribute_name)
-
-
### SVN Functions
def IsSVNMoved(filename):
"""Determine if a file has been added through svn mv"""
- info = GetSVNFileInfo(filename)
+ info = gclient.CaptureSVNInfo(filename)
return (info.get('Copied From URL') and
info.get('Copied From Rev') and
info.get('Schedule') == 'add')
-def GetSVNFileInfo(file):
- """Returns a dictionary from the svn info output for the given file."""
- output = RunShell(["svn", "info", "--xml", file])
- dom = ParseXML(output)
- result = {}
- if dom:
- # /info/entry/
- # url
- # reposityory/(root|uuid)
- # wc-info/(schedule|depth)
- # commit/(author|date)
- result['Node Kind'] = GetNodeNamedAttributeText(dom, 'entry', 'kind')
- result['Repository Root'] = GetNamedNodeText(dom, 'root')
- result['Schedule'] = GetNamedNodeText(dom, 'schedule')
- result['URL'] = GetNamedNodeText(dom, 'url')
- result['Path'] = GetNodeNamedAttributeText(dom, 'entry', 'path')
- result['Copied From URL'] = GetNamedNodeText(dom, 'copy-from-url')
- result['Copied From Rev'] = GetNamedNodeText(dom, 'copy-from-rev')
- return result
-
-
def GetSVNFileProperty(file, property_name):
"""Returns the value of an SVN property for the given file.
@@ -145,7 +102,7 @@
# TODO(maruel): Find the corresponding strings for X, ~
}
output = RunShell(command)
- dom = ParseXML(output)
+ dom = gclient.ParseXML(output)
results = []
if dom:
# /status/target/entry/(wc-status|commit|author|date)
@@ -200,14 +157,16 @@
"""
global repository_root
if not repository_root:
- cur_dir_repo_root = GetSVNFileInfo(os.getcwd()).get("Repository Root")
+ infos = gclient.CaptureSVNInfo(os.getcwd(), print_error=False)
+ cur_dir_repo_root = infos.get("Repository Root")
if not cur_dir_repo_root:
raise Exception("gcl run outside of repository")
repository_root = os.getcwd()
while True:
parent = os.path.dirname(repository_root)
- if GetSVNFileInfo(parent).get("Repository Root") != cur_dir_repo_root:
+ if (gclient.CaptureSVNInfo(parent).get("Repository Root") !=
+ cur_dir_repo_root):
break
repository_root = parent
return repository_root
@@ -230,7 +189,7 @@
cached_settings_file = os.path.join(GetInfoDir(), CODEREVIEW_SETTINGS_FILE)
if (not os.path.exists(cached_settings_file) or
os.stat(cached_settings_file).st_mtime > 60*60*24*3):
- dir_info = GetSVNFileInfo(".")
+ dir_info = gclient.CaptureSVNInfo(".")
repo_root = dir_info["Repository Root"]
url_path = dir_info["URL"]
settings = ""
@@ -753,7 +712,7 @@
for file in files:
# Use svn info output instead of os.path.isdir because the latter fails
# when the file is deleted.
- if GetSVNFileInfo(file).get("Node Kind") in ("dir", "directory"):
+ if gclient.CaptureSVNInfo(file).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
« no previous file with comments | « no previous file | presubmit.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698