| OLD | NEW | 
|    1 # Copyright 2013 The Chromium Authors. All rights reserved. |    1 # Copyright 2013 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 from recipe_engine import recipe_api |    5 from recipe_engine import recipe_api | 
|    6  |    6  | 
|    7  |    7  | 
|    8 class RevisionResolver(object): |    8 class RevisionResolver(object): | 
|    9   """Resolves the revision based on build properties.""" |    9   """Resolves the revision based on build properties.""" | 
|   10  |   10  | 
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  127   def spec_alias(self, name): |  127   def spec_alias(self, name): | 
|  128     self._spec_alias = name |  128     self._spec_alias = name | 
|  129  |  129  | 
|  130   @spec_alias.deleter |  130   @spec_alias.deleter | 
|  131   def spec_alias(self): |  131   def spec_alias(self): | 
|  132     self._spec_alias = None |  132     self._spec_alias = None | 
|  133  |  133  | 
|  134   def get_config_defaults(self): |  134   def get_config_defaults(self): | 
|  135     return { |  135     return { | 
|  136       'USE_MIRROR': self.use_mirror, |  136       'USE_MIRROR': self.use_mirror, | 
|  137       'CACHE_DIR': self.m.infra_paths['git_cache'], |  137       'CACHE_DIR': self.m.path['git_cache'], | 
|  138     } |  138     } | 
|  139  |  139  | 
|  140   @staticmethod |  140   @staticmethod | 
|  141   def config_to_pythonish(cfg): |  141   def config_to_pythonish(cfg): | 
|  142     return jsonish_to_python(cfg.as_jsonish(), True) |  142     return jsonish_to_python(cfg.as_jsonish(), True) | 
|  143  |  143  | 
|  144   def resolve_revision(self, revision): |  144   def resolve_revision(self, revision): | 
|  145     if hasattr(revision, 'resolve'): |  145     if hasattr(revision, 'resolve'): | 
|  146       return revision.resolve(self.m.properties) |  146       return revision.resolve(self.m.properties) | 
|  147     return revision |  147     return revision | 
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  269  |  269  | 
|  270         cfg_cmds = [ |  270         cfg_cmds = [ | 
|  271           ('user.name', 'local_bot'), |  271           ('user.name', 'local_bot'), | 
|  272           ('user.email', 'local_bot@example.com'), |  272           ('user.email', 'local_bot@example.com'), | 
|  273         ] |  273         ] | 
|  274         for var, val in cfg_cmds: |  274         for var, val in cfg_cmds: | 
|  275           name = 'recurse (git config %s)' % var |  275           name = 'recurse (git config %s)' % var | 
|  276           self(name, ['recurse', 'git', 'config', var, val], **kwargs) |  276           self(name, ['recurse', 'git', 'config', var, val], **kwargs) | 
|  277  |  277  | 
|  278     finally: |  278     finally: | 
|  279       cwd = kwargs.get('cwd', self.m.infra_paths['slave_build']) |  279       cwd = kwargs.get('cwd', self.m.path['slave_build']) | 
|  280       if 'checkout' not in self.m.path: |  280       if 'checkout' not in self.m.path: | 
|  281         self.m.path['checkout'] = cwd.join( |  281         self.m.path['checkout'] = cwd.join( | 
|  282           *cfg.solutions[0].name.split(self.m.path.sep)) |  282           *cfg.solutions[0].name.split(self.m.path.sep)) | 
|  283  |  283  | 
|  284     return sync_step |  284     return sync_step | 
|  285  |  285  | 
|  286   def revert(self, **kwargs): |  286   def revert(self, **kwargs): | 
|  287     """Return a gclient_safe_revert step.""" |  287     """Return a gclient_safe_revert step.""" | 
|  288     # Not directly calling gclient, so don't use self(). |  288     # Not directly calling gclient, so don't use self(). | 
|  289     alias = self.spec_alias |  289     alias = self.spec_alias | 
|  290     prefix = '%sgclient ' % (('[spec: %s] ' % alias) if alias else '') |  290     prefix = '%sgclient ' % (('[spec: %s] ' % alias) if alias else '') | 
|  291  |  291  | 
|  292     return self.m.python(prefix + 'revert', |  292     return self.m.python(prefix + 'revert', | 
|  293         self.m.infra_paths['build'].join( |  293         self.m.path['build'].join('scripts', 'slave', 'gclient_safe_revert.py'), | 
|  294             'scripts', 'slave', 'gclient_safe_revert.py'), |  294         ['.', self.m.path['depot_tools'].join('gclient', | 
|  295         [ |  295                                               platform_ext={'win': '.bat'})], | 
|  296             '.', |  | 
|  297             self.m.infra_paths['depot_tools'].join( |  | 
|  298                 'gclient', platform_ext={'win': '.bat'}) |  | 
|  299         ], |  | 
|  300         infra_step=True, |  296         infra_step=True, | 
|  301         **kwargs |  297         **kwargs | 
|  302     ) |  298     ) | 
|  303  |  299  | 
|  304   def runhooks(self, args=None, name='runhooks', **kwargs): |  300   def runhooks(self, args=None, name='runhooks', **kwargs): | 
|  305     args = args or [] |  301     args = args or [] | 
|  306     assert isinstance(args, (list, tuple)) |  302     assert isinstance(args, (list, tuple)) | 
|  307     return self( |  303     return self( | 
|  308       name, ['runhooks'] + list(args), infra_step=False, **kwargs) |  304       name, ['runhooks'] + list(args), infra_step=False, **kwargs) | 
|  309  |  305  | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
|  331  |  327  | 
|  332         build_path = sys.argv[1] |  328         build_path = sys.argv[1] | 
|  333         if os.path.exists(build_path): |  329         if os.path.exists(build_path): | 
|  334           for (path, dir, files) in os.walk(build_path): |  330           for (path, dir, files) in os.walk(build_path): | 
|  335             for cur_file in files: |  331             for cur_file in files: | 
|  336               if cur_file.endswith('index.lock'): |  332               if cur_file.endswith('index.lock'): | 
|  337                 path_to_file = os.path.join(path, cur_file) |  333                 path_to_file = os.path.join(path, cur_file) | 
|  338                 print 'deleting %s' % path_to_file |  334                 print 'deleting %s' % path_to_file | 
|  339                 os.remove(path_to_file) |  335                 os.remove(path_to_file) | 
|  340       """, |  336       """, | 
|  341       args=[self.m.infra_paths['slave_build']], |  337       args=[self.m.path['slave_build']], | 
|  342       infra_step=True, |  338       infra_step=True, | 
|  343     ) |  339     ) | 
|  344  |  340  | 
|  345   def calculate_patch_root(self, patch_project, gclient_config=None): |  341   def calculate_patch_root(self, patch_project, gclient_config=None): | 
|  346     """Returns path where a patch should be applied to based patch_project. |  342     """Returns path where a patch should be applied to based patch_project. | 
|  347  |  343  | 
|  348     Maps "patch_project" to a path of directories relative to checkout's root, |  344     Maps "patch_project" to a path of directories relative to checkout's root, | 
|  349     which describe where to place the patch. |  345     which describe where to place the patch. | 
|  350  |  346  | 
|  351     For now, considers only first solution (c.solutions[0]), but in theory can |  347     For now, considers only first solution (c.solutions[0]), but in theory can | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
|  373     """Updates config revision corresponding to patch_project. |  369     """Updates config revision corresponding to patch_project. | 
|  374  |  370  | 
|  375     Useful for bot_update only, as this is the only consumer of gclient's config |  371     Useful for bot_update only, as this is the only consumer of gclient's config | 
|  376     revision map. This doesn't overwrite the revision if it was already set. |  372     revision map. This doesn't overwrite the revision if it was already set. | 
|  377     """ |  373     """ | 
|  378     assert patch_project is None or isinstance(patch_project, basestring) |  374     assert patch_project is None or isinstance(patch_project, basestring) | 
|  379     cfg = gclient_config or self.c |  375     cfg = gclient_config or self.c | 
|  380     path, revision = cfg.patch_projects.get(patch_project, (None, None)) |  376     path, revision = cfg.patch_projects.get(patch_project, (None, None)) | 
|  381     if path and revision and path not in cfg.revisions: |  377     if path and revision and path not in cfg.revisions: | 
|  382       cfg.revisions[path] = revision |  378       cfg.revisions[path] = revision | 
| OLD | NEW |