Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1291)

Unified Diff: tools/auto_bisect/source_control.py

Issue 504223003: Given git hash, get SVN revision(if available) or Commit position. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/auto_bisect/bisect_utils.py ('k') | tools/bisect-perf-regression_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/auto_bisect/source_control.py
diff --git a/tools/auto_bisect/source_control.py b/tools/auto_bisect/source_control.py
index fa7ded63ed5d8864fa3abc927f85851740207586..fd3c4e336c929c4d02279d3ca7a5f34236824216 100644
--- a/tools/auto_bisect/source_control.py
+++ b/tools/auto_bisect/source_control.py
@@ -5,6 +5,7 @@
"""This module contains the SourceControl class and related functions."""
import os
+import re
from . import bisect_utils
@@ -202,17 +203,22 @@ class GitSourceControl(SourceControl):
return log_output == "master"
- def SVNFindRev(self, revision, cwd=None):
- """Maps directly to the 'git svn find-rev' command.
+ def SVNFindRev(self, git_revision, cwd=None):
+ """Finds a SVN revision OR git number for the given git hash.
+
+ If "git svn find_rev <hash>" fails, then it runs
+ "git log --format=%b -1 origin/master <hash> and greps for
+ Cr-Commit-Position.
Args:
- revision: The git SHA1 to use.
+ git_revision: The git SHA1 to use.
Returns:
- An integer changelist #, otherwise None.
+ Git number (aka git commit position) OR an SVN revision as integer,
+ otherwise None.
"""
- cmd = ['svn', 'find-rev', revision]
+ cmd = ['svn', 'find-rev', git_revision]
output = bisect_utils.CheckRunGit(cmd, cwd)
svn_revision = output.strip()
@@ -220,6 +226,18 @@ class GitSourceControl(SourceControl):
if bisect_utils.IsStringInt(svn_revision):
return int(svn_revision)
+ # Retrieve commit position number from git log body for the given revision.
+ # TODO(prasadv): Use an appropriate command to find commit position instead
+ # of parsing the log. Resolve this once 407316 is fixed.
+ commit_position_pattern = 'Cr-Commit-Position: .*@\{#(?P<commit>[0-9]+)\}'
+ cmd = ['log', '--format=%b', '-1', 'origin/master', git_revision]
+ output = bisect_utils.CheckRunGit(cmd, cwd=cwd)
+ if output:
+ version_re = re.compile(commit_position_pattern)
+ commit_reg = version_re.search(output)
+ if commit_reg and bisect_utils.IsStringInt(commit_reg.group('commit')):
+ return int(commit_reg.group('commit'))
+
return None
def QueryRevisionInfo(self, revision, cwd=None):
« no previous file with comments | « tools/auto_bisect/bisect_utils.py ('k') | tools/bisect-perf-regression_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698