OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
7 | 7 |
8 """A git-command for integrating reviews on Rietveld.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
9 | 9 |
10 import errno | 10 import errno |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 # 2) find the svn-remote that fetches from the URL. | 220 # 2) find the svn-remote that fetches from the URL. |
221 | 221 |
222 # regexp matching the git-svn line that contains the URL. | 222 # regexp matching the git-svn line that contains the URL. |
223 git_svn_re = re.compile(r'^\s*git-svn-id: (\S+)@', re.MULTILINE) | 223 git_svn_re = re.compile(r'^\s*git-svn-id: (\S+)@', re.MULTILINE) |
224 | 224 |
225 # We don't want to go through all of history, so read a line from the | 225 # We don't want to go through all of history, so read a line from the |
226 # pipe at a time. | 226 # pipe at a time. |
227 # The -100 is an arbitrary limit so we don't search forever. | 227 # The -100 is an arbitrary limit so we don't search forever. |
228 cmd = ['git', 'log', '-100', '--pretty=medium'] | 228 cmd = ['git', 'log', '-100', '--pretty=medium'] |
229 proc = Popen(cmd, stdout=subprocess.PIPE) | 229 proc = Popen(cmd, stdout=subprocess.PIPE) |
| 230 url = None |
230 for line in proc.stdout: | 231 for line in proc.stdout: |
231 match = git_svn_re.match(line) | 232 match = git_svn_re.match(line) |
232 if match: | 233 if match: |
233 url = match.group(1) | 234 url = match.group(1) |
234 proc.stdout.close() # Cut pipe. | 235 proc.stdout.close() # Cut pipe. |
235 break | 236 break |
236 | 237 |
237 if url: | 238 if url: |
238 svn_remote_re = re.compile(r'^svn-remote\.([^.]+)\.url (.*)$') | 239 svn_remote_re = re.compile(r'^svn-remote\.([^.]+)\.url (.*)$') |
239 remotes = RunGit(['config', '--get-regexp', | 240 remotes = RunGit(['config', '--get-regexp', |
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1472 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
1472 | 1473 |
1473 # Not a known command. Default to help. | 1474 # Not a known command. Default to help. |
1474 GenUsage(parser, 'help') | 1475 GenUsage(parser, 'help') |
1475 return CMDhelp(parser, argv) | 1476 return CMDhelp(parser, argv) |
1476 | 1477 |
1477 | 1478 |
1478 if __name__ == '__main__': | 1479 if __name__ == '__main__': |
1479 fix_encoding.fix_encoding() | 1480 fix_encoding.fix_encoding() |
1480 sys.exit(main(sys.argv[1:])) | 1481 sys.exit(main(sys.argv[1:])) |
OLD | NEW |