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 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 assert 'stdin' not in kwargs | 129 assert 'stdin' not in kwargs |
| 130 kwargs['stdin'] = subprocess.PIPE | 130 kwargs['stdin'] = subprocess.PIPE |
| 131 ok_ret = kwargs.pop('ok_ret', {0}) | 131 ok_ret = kwargs.pop('ok_ret', {0}) |
| 132 cmd = ('git',) + args | 132 cmd = ('git',) + args |
| 133 | 133 |
| 134 self._log.debug('Running %r', cmd) | 134 self._log.debug('Running %r', cmd) |
| 135 started = time.time() | 135 started = time.time() |
| 136 process = subprocess.Popen(cmd, **kwargs) | 136 process = subprocess.Popen(cmd, **kwargs) |
| 137 output, errout = process.communicate(indata) | 137 output, errout = process.communicate(indata) |
| 138 retcode = process.poll() | 138 retcode = process.poll() |
| 139 self._log.debug('Finished in %.1f sec', time.time() - started) | 139 dt = time.time() - started |
| 140 if dt > 1: # pragma: no cover | |
| 141 self._log.debug('Finished in %.1f sec', dt) | |
| 140 if retcode not in ok_ret: | 142 if retcode not in ok_ret: |
| 141 raise CalledProcessError(retcode, cmd, output, errout) | 143 raise CalledProcessError(retcode, cmd, output, errout) |
| 142 | 144 |
| 143 if errout: | 145 if errout: |
| 144 sys.stderr.write(errout) | 146 sys.stderr.write(errout) |
| 145 return output | 147 return output |
| 146 | 148 |
| 147 def intern(self, data, typ='blob'): | 149 def intern(self, data, typ='blob'): |
| 148 return self.run( | 150 return self.run( |
| 149 'hash-object', '-w', '-t', typ, '--stdin', indata=str(data)).strip() | 151 'hash-object', '-w', '-t', typ, '--stdin', indata=str(data)).strip() |
| 152 | |
| 153 def fast_forward_push(self, refs_and_commits): | |
| 154 """Push commits to refs on the remote, and also update refs' local copies. | |
|
iannucci
2014/07/30 19:28:18
make it clear that the ref in the dictionary is th
Vadim Sh.
2014/07/30 20:15:35
Done.
| |
| 155 | |
| 156 Args: | |
| 157 refs_and_commits: dict {Ref object -> Commit to push to the ref}. | |
| 158 """ | |
| 159 refspec = [ | |
| 160 '%s:%s' % (c.hsh, r.ref) | |
| 161 for r, c in refs_and_commits.iteritems() | |
| 162 ] | |
| 163 self.run('push', 'origin', *refspec) | |
|
iannucci
2014/07/30 19:28:18
is there a minimum git version which is required f
Vadim Sh.
2014/07/30 20:15:35
I don't think so. Help page for 1.7.5 already ment
| |
| 164 for r, c in refs_and_commits.iteritems(): | |
| 165 r.update_to(c) | |
| OLD | NEW |