| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2011 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 """SCM-specific utility classes.""" | 5 """SCM-specific utility classes.""" |
| 6 | 6 |
| 7 import cStringIO | 7 import cStringIO |
| 8 import glob | 8 import glob |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 # 1) iterate through our branch history and find the svn URL. | 219 # 1) iterate through our branch history and find the svn URL. |
| 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 = subprocess2.Popen(cmd, cwd, stdout=subprocess2.PIPE) | 229 proc = subprocess2.Popen(cmd, cwd=cwd, stdout=subprocess2.PIPE) |
| 230 url = None | 230 url = None |
| 231 for line in proc.stdout: | 231 for line in proc.stdout: |
| 232 match = git_svn_re.match(line) | 232 match = git_svn_re.match(line) |
| 233 if match: | 233 if match: |
| 234 url = match.group(1) | 234 url = match.group(1) |
| 235 proc.stdout.close() # Cut pipe. | 235 proc.stdout.close() # Cut pipe. |
| 236 break | 236 break |
| 237 | 237 |
| 238 if url: | 238 if url: |
| 239 svn_remote_re = re.compile(r'^svn-remote\.([^.]+)\.url (.*)$') | 239 svn_remote_re = re.compile(r'^svn-remote\.([^.]+)\.url (.*)$') |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 # revert, like for properties. | 1004 # revert, like for properties. |
| 1005 if not os.path.isdir(cwd): | 1005 if not os.path.isdir(cwd): |
| 1006 # '.' was deleted. It's not worth continuing. | 1006 # '.' was deleted. It's not worth continuing. |
| 1007 return | 1007 return |
| 1008 try: | 1008 try: |
| 1009 SVN.Capture(['revert', file_status[1]], cwd=cwd) | 1009 SVN.Capture(['revert', file_status[1]], cwd=cwd) |
| 1010 except subprocess2.CalledProcessError: | 1010 except subprocess2.CalledProcessError: |
| 1011 if not os.path.exists(file_path): | 1011 if not os.path.exists(file_path): |
| 1012 continue | 1012 continue |
| 1013 raise | 1013 raise |
| OLD | NEW |