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

Unified Diff: gclient.py

Issue 113086: Change CaptureSVNInfo() to return a dictionary instead of a object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' 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 | tests/gclient_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient.py
===================================================================
--- gclient.py (revision 15714)
+++ gclient.py (working copy)
@@ -557,19 +557,18 @@
def CaptureSVNInfo(options, relpath, in_directory):
- """Runs 'svn info' on an existing path.
+ """Returns a dictionary from the svn info output for the given file.
Args:
relpath: The directory where the working copy resides relative to
the directory given by in_directory.
in_directory: The directory where svn is to be run.
-
- Returns:
- An object with fields corresponding to the output of 'svn info'
"""
dom = ParseXML(CaptureSVN(options, ["info", "--xml", relpath], in_directory))
- result = PrintableObject()
+ result = {}
if dom:
+ def C(item, f):
+ if item is not None: return f(item)
# /info/entry/
# url
# reposityory/(root|uuid)
@@ -578,11 +577,18 @@
# str() the results because they may be returned as Unicode, which
# interferes with the higher layers matching up things in the deps
# dictionary.
- result = PrintableObject()
- result.root = str(GetNamedNodeText(dom, 'root'))
- result.url = str(GetNamedNodeText(dom, 'url'))
- result.uuid = str(GetNamedNodeText(dom, 'uuid'))
- result.revision = int(GetNodeNamedAttributeText(dom, 'entry', 'revision'))
+ # TODO(maruel): Fix at higher level instead (!)
+ result['Repository Root'] = C(GetNamedNodeText(dom, 'root'), str)
+ result['URL'] = C(GetNamedNodeText(dom, 'url'), str)
+ result['UUID'] = C(GetNamedNodeText(dom, 'uuid'), str)
+ result['Revision'] = C(GetNodeNamedAttributeText(dom, 'entry', 'revision'),
+ int)
+ result['Node Kind'] = C(GetNodeNamedAttributeText(dom, 'entry', 'kind'),
+ str)
+ result['Schedule'] = C(GetNamedNodeText(dom, 'schedule'), str)
+ result['Path'] = C(GetNodeNamedAttributeText(dom, 'entry', 'path'), str)
+ result['Copied From URL'] = C(GetNamedNodeText(dom, 'copy-from-url'), str)
+ result['Copied From Rev'] = C(GetNamedNodeText(dom, 'copy-from-rev'), str)
return result
@@ -781,17 +787,21 @@
if options.manually_grab_svn_rev:
# Retrieve the current HEAD version because svn is slow at null updates.
if not revision:
- from_info_live = CaptureSVNInfo(options, from_info.url, '.')
- revision = int(from_info_live.revision)
+ from_info_live = CaptureSVNInfo(options, from_info['URL'], '.')
+ revision = int(from_info_live['Revision'])
rev_str = ' at %d' % revision
- if from_info.url != components[0]:
+ if from_info['URL'] != components[0]:
to_info = CaptureSVNInfo(options, url, '.')
- if from_info.root != to_info.root:
+ if from_info['Repository Root'] != to_info['Repository Root']:
# We have different roots, so check if we can switch --relocate.
# Subversion only permits this if the repository UUIDs match.
- if from_info.uuid != to_info.uuid:
- raise Error("Can't switch the checkout to %s; UUID don't match" % url)
+ if from_info['UUID'] != to_info['UUID']:
+ raise Error("Can't switch the checkout to %s; UUID don't match. That "
+ "simply means in theory, gclient should verify you don't "
+ "have a local change, remove the old checkout and do a "
+ "fresh new checkout of the new repo. Contributions are "
+ "welcome." % url)
# Perform the switch --relocate, then rewrite the from_url
# to reflect where we "are now." (This is the same way that
@@ -800,14 +810,18 @@
# can update to a revision or have to switch to a different
# branch work as expected.
# TODO(maruel): TEST ME !
- command = ["switch", "--relocate", from_info.root, to_info.root,
+ command = ["switch", "--relocate",
+ from_info['Repository Root'],
+ to_info['Repository Root'],
self.relpath]
RunSVN(options, command, self._root_dir)
- from_info.url = from_info.url.replace(from_info.root, to_info.root)
+ from_info['URL'] = from_info['URL'].replace(
+ from_info['Repository Root'],
+ to_info['Repository Root'])
# If the provided url has a revision number that matches the revision
# number of the existing directory, then we don't need to bother updating.
- if not options.force and from_info.revision == revision:
+ if not options.force and from_info['Revision'] == revision:
if options.verbose or not forced_revision:
print >>options.stdout, ("\n_____ %s%s" % (
self.relpath, rev_str))
« no previous file with comments | « no previous file | tests/gclient_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698