| 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 import collections | 5 import collections |
| 6 import errno | 6 import errno |
| 7 import fnmatch | 7 import fnmatch |
| 8 import logging | 8 import logging |
| 9 import os | 9 import os |
| 10 import subprocess | 10 import subprocess |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 def __init__(self, url): | 30 def __init__(self, url): |
| 31 self.dry_run = False | 31 self.dry_run = False |
| 32 self.repos_dir = None | 32 self.repos_dir = None |
| 33 | 33 |
| 34 self._url = url | 34 self._url = url |
| 35 self._repo_path = None | 35 self._repo_path = None |
| 36 self._commit_cache = collections.OrderedDict() | 36 self._commit_cache = collections.OrderedDict() |
| 37 self._log = LOGGER.getChild('Repo') | 37 self._log = LOGGER.getChild('Repo') |
| 38 | 38 |
| 39 def __hash__(self): |
| 40 return hash((self._url, self._repo_path)) |
| 41 |
| 39 def __getitem__(self, ref): | 42 def __getitem__(self, ref): |
| 40 """Get a Ref attached to this Repo.""" | 43 """Get a Ref attached to this Repo.""" |
| 41 return Ref(self, ref) | 44 return Ref(self, ref) |
| 42 | 45 |
| 43 # Accessors | 46 # Accessors |
| 44 # pylint: disable=W0212 | 47 # pylint: disable=W0212 |
| 45 url = property(lambda self: self._url) | 48 url = property(lambda self: self._url) |
| 46 repo_path = property(lambda self: self._repo_path) | 49 repo_path = property(lambda self: self._repo_path) |
| 47 | 50 |
| 48 def reify(self, share_from=None): | 51 def reify(self, share_from=None): |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 """ | 194 """ |
| 192 if not refs_and_commits: | 195 if not refs_and_commits: |
| 193 return | 196 return |
| 194 refspec = [ | 197 refspec = [ |
| 195 '%s:%s' % (c.hsh, r.ref) | 198 '%s:%s' % (c.hsh, r.ref) |
| 196 for r, c in refs_and_commits.iteritems() | 199 for r, c in refs_and_commits.iteritems() |
| 197 ] | 200 ] |
| 198 self.run('push', 'origin', *refspec) | 201 self.run('push', 'origin', *refspec) |
| 199 for r, c in refs_and_commits.iteritems(): | 202 for r, c in refs_and_commits.iteritems(): |
| 200 r.update_to(c) | 203 r.update_to(c) |
| OLD | NEW |