From 98023dfb35d9d38e6647545fbd079a8ea5dd3cca Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Wed, 7 Sep 2011 18:44:47 +0000 Subject: [PATCH] Urls with /@ won't be processed correctly when used as a requirements. This is important for parallel checkout. R=dpranke@chromium.org BUG= TEST= Review URL: http://codereview.chromium.org/7840033 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@99981 0039d316-1c4b-4281-b951-d872f2087c98 --- gclient.py | 14 ++++++++++++-- tests/gclient_test.py | 7 +++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gclient.py b/gclient.py index e2257724e..69b524c32 100644 --- a/gclient.py +++ b/gclient.py @@ -172,6 +172,14 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem): # Required dependencies to run before running this one: self.requirements = set() + # Post process the url to remove trailing slashes. + if isinstance(self.url, basestring): + # urls are sometime incorrectly written as proto://host/path/@rev. Replace + # it to proto://host/path@rev. + if self.url.count('@') > 1: + raise gclient_utils.Error('Invalid url "%s"' % self.url) + self.url = self.url.replace('/@', '@') + self._FindDependencies() # Sanity checks @@ -263,8 +271,10 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem): break if not found_dep: raise gclient_utils.Error( - 'Couldn\'t find %s in %s, referenced by %s\n%s' % ( - sub_target, ref.name, self.name, str(self.root_parent()))) + 'Couldn\'t find %s in %s, referenced by %s (parent: %s)\n%s' % ( + sub_target, ref.name, self.name, self.parent.name, + str(self.root_parent()))) + # Call LateOverride() again. parsed_url = found_dep.LateOverride(found_dep.url) logging.info('%s, %s to %s' % (self.name, url, parsed_url)) diff --git a/tests/gclient_test.py b/tests/gclient_test.py index ecbf0357b..c136dc271 100755 --- a/tests/gclient_test.py +++ b/tests/gclient_test.py @@ -181,6 +181,13 @@ class GclientTest(trial_dir.TestCase): pass return items + def testAutofix(self): + # Invalid urls causes pain when specifying requirements. Make sure it's + # auto-fixed. + d = gclient.Dependency( + None, 'name', 'proto://host/path/@revision', None, None, + None, '', True) + self.assertEquals('proto://host/path@revision', d.url) if __name__ == '__main__': logging.basicConfig(