Chromium Code Reviews| Index: tools/utils.py |
| diff --git a/tools/utils.py b/tools/utils.py |
| index f4a37553c5ede21e3f24afe4e684b5ab465dea25..fc55a5b1cfd7dc8789f10310cc97e80807bf35e0 100644 |
| --- a/tools/utils.py |
| +++ b/tools/utils.py |
| @@ -366,11 +366,13 @@ def GetSVNRevision(): |
| if revision: |
| return revision |
| - # maybe the builder is using git-svn, try that |
| - p = subprocess.Popen(['git', 'svn', 'info'], stdout = subprocess.PIPE, |
| + # Check for revision using git (Note: we can't use git-svn because in a |
| + # pure-git checkout, "git-svn anyCommand" just hangs!). We look an arbitrary |
| + # number of commits backwards (100) to get past any local commits. |
|
ricow1
2014/06/10 10:44:10
will this actually give the correct revision?
Emily Fortuna
2014/06/10 16:08:47
Yup, as long as there are no more than 100 local c
|
| + p = subprocess.Popen(['git', 'log', '-100'], stdout = subprocess.PIPE, |
| stderr = subprocess.STDOUT, shell=IsWindows(), cwd = DART_DIR) |
|
Emily Fortuna
2014/06/09 17:45:41
Yeah, the 100 is gross, but better than hanging in
|
| output, _ = p.communicate() |
| - revision = ParseSvnInfoOutput(output) |
| + revision = ParseGitInfoOutput(output) |
| if revision: |
|
blois
2014/06/16 19:20:12
Could fall back to git svn info if this fails, jus
|
| return revision |
| @@ -381,6 +383,14 @@ def GetSVNRevision(): |
| return None |
| +def ParseGitInfoOutput(output): |
| + """Given a git log, determine the latest corresponding svn revision.""" |
| + for line in output.split('\n'): |
| + tokens = line.split() |
| + if len(tokens) > 0 and tokens[0] == 'git-svn-id:': |
| + return tokens[1].split('@')[1] |
| + return None |
| + |
| def ParseSvnInfoOutput(output): |
| revision_match = re.search('Last Changed Rev: (\d+)', output) |
| if revision_match: |