Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 class Dependency(object): | 6 class Dependency(object): |
| 7 """Represent a dependency in Chrome, like blink, v8, pdfium, etc.""" | 7 """Represents a dependency in Chrome, like blink, v8, pdfium, etc.""" |
| 8 def __init__(self, path, repo_url, revision, deps_file): | 8 def __init__(self, path, repo_url, revision, deps_file='DEPS'): |
| 9 self.path = path | 9 self.path = path |
| 10 self.repo_url = repo_url | 10 self.repo_url = repo_url |
| 11 self.revision = revision | 11 self.revision = revision |
| 12 self.deps_file = deps_file | 12 self.deps_file = deps_file |
| 13 self.parent = None | 13 self.parent = None |
| 14 self.children = dict() | 14 self.children = dict() |
| 15 | 15 |
| 16 def SetParent(self, parent): | 16 def SetParent(self, parent): |
| 17 assert self.parent is None | 17 assert self.parent is None |
| 18 self.parent = parent | 18 self.parent = parent |
| 19 self.parent.AddChild(self) | 19 self.parent.AddChild(self) |
| 20 | 20 |
| 21 def AddChild(self, child): | 21 def AddChild(self, child): |
| 22 self.children[child.path] = child | 22 self.children[child.path] = child |
| 23 | 23 |
| 24 def ToDict(self): | 24 def ToDict(self): |
| 25 children_dict = {} | 25 children_dict = {} |
| 26 for path, child in self.children.iteritems(): | 26 for path, child in self.children.iteritems(): |
| 27 children_dict[path] = child.ToDict() | 27 children_dict[path] = child.ToDict() |
| 28 return { | 28 return { |
| 29 'path': self.path, | 29 'path': self.path, |
| 30 'repo_url': self.repo_url, | 30 'repo_url': self.repo_url, |
| 31 'revision': self.revision, | 31 'revision': self.revision, |
| 32 'deps_file': self.deps_file, | 32 'deps_file': self.deps_file, |
| 33 'children': children_dict, | 33 'children': children_dict, |
| 34 } | 34 } |
| 35 | |
| 36 | |
| 37 class DependencyRoll(object): | |
| 38 """Represents a dependency roll (revision update) in chromium.""" | |
| 39 def __init__(self, path, repo_url, old_revision, new_revision): | |
| 40 # Note: It is possible that the DEPS roll is a revert so that |new_revision| | |
| 41 # is actually older than |old_revision| in the dependency. | |
| 42 self.path = path | |
| 43 self.repo_url = repo_url | |
| 44 self.old_revision = old_revision | |
| 45 self.new_revision = new_revision | |
| 46 | |
| 47 def ToDict(self): | |
| 48 return { | |
| 49 'path': self.path, | |
| 50 'repo_url': self.repo_url, | |
| 51 'old_revision': self.old_revision, | |
| 52 'new_revision': self.new_revision, | |
| 53 } | |
|
qyearsley
2015/05/29 23:14:33
Classes like this could also be made shorter by be
stgao
2015/05/30 00:21:05
That's a good idea!
Done.
| |
| OLD | NEW |