diff options
author | mnaganov <mnaganov@chromium.org> | 2015-06-18 16:16:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-18 23:16:45 +0000 |
commit | b73e2ea7a4e319eb2e6183090dfe6b9796d42c3b (patch) | |
tree | e3c852951b64bbfb9b34a68e26c99c11943d06af /build | |
parent | 2d473c4f335c970c3523dbdbd5684632ef6e6a67 (diff) | |
download | chromium_src-b73e2ea7a4e319eb2e6183090dfe6b9796d42c3b.zip chromium_src-b73e2ea7a4e319eb2e6183090dfe6b9796d42c3b.tar.gz chromium_src-b73e2ea7a4e319eb2e6183090dfe6b9796d42c3b.tar.bz2 |
Restore under flag historic behaviour of lastchange.py wrt. Git-SVN repos
Adds optional flag '--git-svn-go-deeper' to allow lastchange.py find
the last committed SVN revision in a Git-SVN repo.
This is to help access DevTools frontend on Android for Chromium developers
that have local changes to Blink.
BUG=468691
Review URL: https://codereview.chromium.org/1197483002
Cr-Commit-Position: refs/heads/master@{#335156}
Diffstat (limited to 'build')
-rwxr-xr-x | build/util/lastchange.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/build/util/lastchange.py b/build/util/lastchange.py index 1a7f519..3f3ee4a 100755 --- a/build/util/lastchange.py +++ b/build/util/lastchange.py @@ -121,7 +121,7 @@ def FetchGitRevision(directory): return VersionInfo('git', '%s-%s' % (hsh, pos)) -def FetchGitSVNURLAndRevision(directory, svn_url_regex): +def FetchGitSVNURLAndRevision(directory, svn_url_regex, go_deeper): """ Fetch the Subversion URL and revision through Git. @@ -130,7 +130,10 @@ def FetchGitSVNURLAndRevision(directory, svn_url_regex): Returns: A tuple containing the Subversion URL and revision. """ - proc = RunGitCommand(directory, ['log', '-1', '--format=%b']) + git_args = ['log', '-1', '--format=%b'] + if go_deeper: + git_args.append('--grep=git-svn-id') + proc = RunGitCommand(directory, git_args) if proc: output = proc.communicate()[0].strip() if proc.returncode == 0 and output: @@ -149,20 +152,21 @@ def FetchGitSVNURLAndRevision(directory, svn_url_regex): return None, None -def FetchGitSVNRevision(directory, svn_url_regex): +def FetchGitSVNRevision(directory, svn_url_regex, go_deeper): """ Fetch the Git-SVN identifier for the local tree. Errors are swallowed. """ - url, revision = FetchGitSVNURLAndRevision(directory, svn_url_regex) + url, revision = FetchGitSVNURLAndRevision(directory, svn_url_regex, go_deeper) if url and revision: return VersionInfo(url, revision) return None def FetchVersionInfo(default_lastchange, directory=None, - directory_regex_prior_to_src_url='chrome|blink|svn'): + directory_regex_prior_to_src_url='chrome|blink|svn', + go_deeper=False): """ Returns the last change (in the form of a branch, revision tuple), from some appropriate revision control system. @@ -171,7 +175,7 @@ def FetchVersionInfo(default_lastchange, directory=None, r'.*/(' + directory_regex_prior_to_src_url + r')(/.*)') version_info = (FetchSVNRevision(directory, svn_url_regex) or - FetchGitSVNRevision(directory, svn_url_regex) or + FetchGitSVNRevision(directory, svn_url_regex, go_deeper) or FetchGitRevision(directory)) if not version_info: if default_lastchange and os.path.exists(default_lastchange): @@ -256,6 +260,9 @@ def main(argv=None): "file-output-related options.") parser.add_option("-s", "--source-dir", metavar="DIR", help="Use repository in the given directory.") + parser.add_option("--git-svn-go-deeper", action='store_true', + help="In a Git-SVN repo, dig down to the last committed " + + "SVN change (historic behaviour).") opts, args = parser.parse_args(argv[1:]) out_file = opts.output @@ -274,7 +281,9 @@ def main(argv=None): else: src_dir = os.path.dirname(os.path.abspath(__file__)) - version_info = FetchVersionInfo(opts.default_lastchange, src_dir) + version_info = FetchVersionInfo(opts.default_lastchange, + directory=src_dir, + go_deeper=opts.git_svn_go_deeper) if version_info.revision == None: version_info.revision = '0' |