Commit 4ad264bf authored by szager@chromium.org's avatar szager@chromium.org

Enable --revision flag for all deps.

Currently, only top-level solutions may be pinned via --revision.  With this, we can:

gclient sync --revision src/third_party/WebKit@deadbeef

BUG=

Review URL: https://codereview.chromium.org/290443003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@271571 0039d316-1c4b-4281-b951-d872f2087c98
parent 10fbe879
...@@ -313,6 +313,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -313,6 +313,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
# This is the scm used to checkout self.url. It may be used by dependencies # This is the scm used to checkout self.url. It may be used by dependencies
# to get the datetime of the revision we checked out. # to get the datetime of the revision we checked out.
self._used_scm = None self._used_scm = None
self._used_revision = None
# The actual revision we ended up getting, or None if that information is # The actual revision we ended up getting, or None if that information is
# unavailable # unavailable
self._got_revision = None self._got_revision = None
...@@ -601,8 +602,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -601,8 +602,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
self.add_dependency(dep) self.add_dependency(dep)
self._mark_as_parsed(hooks) self._mark_as_parsed(hooks)
def maybeGetParentRevision( def maybeGetParentRevision(self, command, options, parsed_url, parent):
self, command, options, parsed_url, parent_name, revision_overrides):
"""Uses revision/timestamp of parent if no explicit revision was specified. """Uses revision/timestamp of parent if no explicit revision was specified.
If we are performing an update and --transitive is set, use If we are performing an update and --transitive is set, use
...@@ -615,7 +615,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -615,7 +615,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
if command == 'update' and options.transitive and not options.revision: if command == 'update' and options.transitive and not options.revision:
_, revision = gclient_utils.SplitUrlRevision(parsed_url) _, revision = gclient_utils.SplitUrlRevision(parsed_url)
if not revision: if not revision:
options.revision = revision_overrides.get(parent_name) options.revision = getattr(parent, '_used_revision', None)
if (options.revision and if (options.revision and
not gclient_utils.IsDateRevision(options.revision)): not gclient_utils.IsDateRevision(options.revision)):
assert self.parent and self.parent.used_scm assert self.parent and self.parent.used_scm
...@@ -636,7 +636,6 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -636,7 +636,6 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
if options.verbose: if options.verbose:
print('Using parent\'s revision date %s since we are in a ' print('Using parent\'s revision date %s since we are in a '
'different repository.' % options.revision) 'different repository.' % options.revision)
revision_overrides[self.name] = options.revision
# Arguments number differs from overridden method # Arguments number differs from overridden method
# pylint: disable=W0221 # pylint: disable=W0221
...@@ -667,9 +666,10 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): ...@@ -667,9 +666,10 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
else: else:
# Create a shallow copy to mutate revision. # Create a shallow copy to mutate revision.
options = copy.copy(options) options = copy.copy(options)
options.revision = revision_overrides.get(self.name) options.revision = revision_overrides.pop(self.name, None)
self.maybeGetParentRevision( self.maybeGetParentRevision(
command, options, parsed_url, self.parent.name, revision_overrides) command, options, parsed_url, self.parent)
self._used_revision = options.revision
self._used_scm = gclient_scm.CreateSCM( self._used_scm = gclient_scm.CreateSCM(
parsed_url, self.root.root_dir, self.name, self.outbuf, parsed_url, self.root.root_dir, self.name, self.outbuf,
out_cb=work_queue.out_cb) out_cb=work_queue.out_cb)
...@@ -1218,13 +1218,8 @@ want to set 'managed': False in .gclient. ...@@ -1218,13 +1218,8 @@ want to set 'managed': False in .gclient.
if not '@' in revision: if not '@' in revision:
# Support for --revision 123 # Support for --revision 123
revision = '%s@%s' % (solutions_names[index], revision) revision = '%s@%s' % (solutions_names[index], revision)
sol, rev = revision.split('@', 1) name, rev = revision.split('@', 1)
if not sol in solutions_names: revision_overrides[name] = rev
#raise gclient_utils.Error('%s is not a valid solution.' % sol)
print >> sys.stderr, ('Please fix your script, having invalid '
'--revision flags will soon considered an error.')
else:
revision_overrides[sol] = rev
index += 1 index += 1
return revision_overrides return revision_overrides
...@@ -1278,6 +1273,9 @@ want to set 'managed': False in .gclient. ...@@ -1278,6 +1273,9 @@ want to set 'managed': False in .gclient.
for s in self.dependencies: for s in self.dependencies:
work_queue.enqueue(s) work_queue.enqueue(s)
work_queue.flush(revision_overrides, command, args, options=self._options) work_queue.flush(revision_overrides, command, args, options=self._options)
if revision_overrides:
print >> sys.stderr, ('Please fix your script, having invalid '
'--revision flags will soon considered an error.')
# Once all the dependencies have been processed, it's now safe to run the # Once all the dependencies have been processed, it's now safe to run the
# hooks. # hooks.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment