haikuwebkit/Websites/perf.webkit.org/tools/sync-commits.py

311 lines
14 KiB
Python
Raw Permalink Normal View History

Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
#!/usr/bin/python
import argparse
import json
import os.path
import re
import subprocess
import sys
import time
import urllib2
from datetime import datetime
from abc import ABCMeta, abstractmethod
from xml.dom.minidom import parseString as parseXmlString
from util import load_server_config
from util import submit_commits
from util import text_content
# There are some buggy commit messages:
# Canonical link: https://commits.webkit.org/https://commits.webkit.org/232477@main
REVISION_IDENTIFIER_RE = re.compile(r'Canonical link: (https\://commits\.webkit\.org/)+(?P<revision_identifier>\d+@[\w\.\-]+)\n')
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
def main(argv):
parser = argparse.ArgumentParser()
parser.add_argument('--repository-config-json', required=True, help='The path to a JSON file that specifies subversion syncing options')
parser.add_argument('--server-config-json', required=True, help='The path to a JSON file that specifies the perf dashboard')
parser.add_argument('--seconds-to-sleep', type=float, default=900, help='The seconds to sleep between iterations')
parser.add_argument('--max-fetch-count', type=int, default=10, help='The number of commits to fetch at once')
parser.add_argument('--max-ancestor-fetch-count', type=int, default=100, help='The number of commits to fetch at once if some commits are missing previous commits')
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
args = parser.parse_args()
with open(args.repository_config_json) as repository_config_json:
repositories = [load_repository(repository_info) for repository_info in json.load(repository_config_json)]
while True:
server_config = load_server_config(args.server_config_json)
for repository in repositories:
try:
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
repository.fetch_commits_and_submit(server_config, args.max_fetch_count, args.max_ancestor_fetch_count)
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
except Exception as error:
print "Failed to fetch and sync:", error
print "Sleeping for %d seconds..." % args.seconds_to_sleep
time.sleep(args.seconds_to_sleep)
def load_repository(repository):
if 'gitCheckout' in repository:
return GitRepository(
name=repository['name'], git_url=repository['url'], git_checkout=repository['gitCheckout'],
git_branch=repository.get('branch'), report_revision_identifier_in_commit_msg=repository.get('reportRevisionIdentifier'),
report_svn_revison=repository.get('reportSVNRevision'))
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
return SVNRepository(name=repository['name'], svn_url=repository['url'], should_trust_certificate=repository.get('trustCertificate', False),
use_server_auth=repository.get('useServerAuth', False), account_name_script_path=repository.get('accountNameFinderScript'))
class Repository(object):
___metaclass___ = ABCMeta
_name_account_compound_regex = re.compile(r'^\s*(?P<name>(\".+\"|[^<]+?))\s*\<(?P<account>.+)\>\s*$')
def __init__(self, name):
self._name = name
self._last_fetched = None
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
def fetch_commits_and_submit(self, server_config, max_fetch_count, max_ancestor_fetch_count):
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
if not self._last_fetched:
Rewrite 'pull-os-versions' script in Javascript to add support for reporting os revisions with sub commits. https://bugs.webkit.org/show_bug.cgi?id=169542 Reviewed by Ryosuke Niwa. Extend '/api/commits/<repository>/last-reported' to accept a range and return last reported commits in given range. Rewrite 'pull-os-versions' in JavaScript and add unit tests for it. Instead of writing query manually while searching criteria contains null columns, use the methods provided in 'db.php'. Add '.gitignore' file to ommit files generated by while running tests/instances locally. * .gitignore: Added. * public/api/commits.php: * public/api/report-commits.php: * public/include/commit-log-fetcher.php: * public/include/db.php: 'null_columns' of prepare_params should be a reference. * public/include/report-processor.php: * server-tests/api-commits.js: (then): * server-tests/api-report-commits-tests.js: * server-tests/resources/mock-logger.js: Added. (MockLogger): (MockLogger.prototype.log): (MockLogger.prototype.error): * server-tests/resources/mock-subprocess.js: Added. (MockSubprocess.call): (MockSubprocess.waitingForInvocation): (MockSubprocess.inject): (MockSubprocess.reset): * server-tests/tools-buildbot-triggerable-tests.js: (MockLogger): Deleted. (MockLogger.prototype.log): Deleted. (MockLogger.prototype.error): Deleted. * server-tests/tools-os-build-fetcher-tests.js: Added. (beforeEach): (return.waitingForInvocationPromise.then): (then): (string_appeared_here.return.waitingForInvocationPromise.then): (return.addSlaveForReport.emptyReport.then): * tools/js/os-build-fetcher.js: Added. (OSBuildFetcher): (OSBuildFetcher.prototype._fetchAvailableBuilds): (OSBuildFetcher.prototype._computeOrder): (OSBuildFetcher.prototype._commitsForAvailableBuilds.return.this._subprocess.call.then.): (OSBuildFetcher.prototype._commitsForAvailableBuilds): (OSBuildFetcher.prototype._addSubCommitsForBuild): (OSBuildFetcher.prototype._submitCommits): (OSBuildFetcher.prototype.fetchAndReportNewBuilds): * tools/js/subprocess.js: Added. (const.childProcess.require.string_appeared_here.Subprocess.prototype.call): (const.childProcess.require.string_appeared_here.Subprocess): * tools/pull-os-versions.js: Added. (main): (syncLoop): * tools/sync-commits.py: (Repository.fetch_commits_and_submit): Canonical link: https://commits.webkit.org/186651@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213976 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-15 08:35:07 +00:00
print "Determining the starting revision for %s" % self._name
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
self._last_fetched = self.determine_last_reported_revision(server_config)
pending_commits = []
for unused in range(max_fetch_count):
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
commit = self.fetch_next_commit(server_config, self._last_fetched)
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
if not commit:
break
pending_commits += [commit]
self._last_fetched = commit['revision']
if not pending_commits:
print "No new revision found for %s (last fetched: %s)" % (self._name, self.format_revision(self._last_fetched))
return
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
for unused in range(max_ancestor_fetch_count):
revision_list = ', '.join([self.format_revision(commit['revision']) for commit in pending_commits])
print "Submitting revisions %s for %s to %s" % (revision_list, self._name, server_config['server']['url'])
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
result = submit_commits(pending_commits, server_config['server']['url'],
[perf dashboard] Remove non-inclusive words from perf dashboard. https://bugs.webkit.org/show_bug.cgi?id=223505 Reviewed by Ryosuke Niwa. Removed most of non-inclusive terminology and replaced it with 'worker'. Make impacted APIs backward compatible during transition. The non-inclusive terminology will be removed after transition. * ReadMe.md: Removed non-inclusive words. * init-database.sql: Rename tables with non-inclusive words. * migrate-database.sql: Added migration SQL for existing database. * public/admin/build-workers.php: Renamed from Websites/perf.webkit.org/public/admin/build-slaves.php. * public/api/build-requests.php: * public/api/measurement-set.php: * public/api/report-commits.php: * public/api/runs.php: * public/api/update-triggerable.php: * public/api/upload-root.php: * public/include/admin-header.php: * public/include/json-header.php: * public/include/report-processor.php: * public/privileged-api/add-build-requests.php: * public/privileged-api/create-analysis-task.php: * public/privileged-api/create-test-group.php: * public/privileged-api/update-test-group.php: * public/v2/js/ember.js: * server-tests/api-build-requests-tests.js: * server-tests/api-commits-tests.js: * server-tests/api-report-commits-tests.js: * server-tests/api-report-tests.js: (emptyReport): (reportWitMismatchingCommitTime): (reportWithOneSecondCommitTimeDifference): (emptyWorkerReport): (emptySlaveReport): Deleted. * server-tests/api-test-groups.js: * server-tests/api-update-triggerable-tests.js: (updateWithOSXRepositoryGroup): (updateWithMacWebKitRepositoryGroups): * server-tests/api-upload-root-tests.js: (makeReport): (addWorkerAndCreateRootFile): * server-tests/privileged-api-add-build-requests-tests.js: (async createAnalysisTask): (async addTriggerableAndCreateTask): * server-tests/privileged-api-create-analysis-task-tests.js: * server-tests/privileged-api-create-test-group-tests.js: (createAnalysisTask): * server-tests/privileged-api-update-test-group-tests.js: (async createAnalysisTask): (async addTriggerableAndCreateTask): * server-tests/resources/common-operations.js: * server-tests/resources/mock-data.js: (MockData.addMockConfiguration): (MockData.set mockTestSyncConfigWithSingleBuilder): (MockData.sampleBuildData): * server-tests/resources/test-server.js: (TestServer.prototype.testConfig): * server-tests/tools-buildbot-triggerable-tests.js: * server-tests/tools-os-build-fetcher-tests.js: * server-tests/tools-sync-buildbot-integration-tests.js: (createTriggerable): * tools/detect-changes.js: (loadServerConfig): * tools/js/buildbot-syncer.js: (BuildbotBuildEntry.prototype.buildTag): (BuildbotSyncer): (BuildbotSyncer.prototype.scheduleRequest): (BuildbotSyncer.prototype.scheduleRequestInGroupIfAvailable): (BuildbotSyncer.prototype.pullBuildbot): (BuildbotSyncer._loadConfig): (BuildbotSyncer._validateAndMergeConfig): (BuildbotBuildEntry.prototype.slaveName): Deleted. * tools/js/buildbot-triggerable.js: (BuildbotTriggerable): (BuildbotTriggerable.prototype.updateTriggerable): (BuildbotTriggerable.prototype.async syncOnce): (BuildbotTriggerable.prototype.async _scheduleRequest): (BuildbotTriggerable.prototype._scheduleRequestIfWorkerIsAvailable): (BuildbotTriggerable.prototype._scheduleRequestWithLog): (BuildbotTriggerable._testGroupMapForBuildRequests): (BuildbotTriggerable.prototype._scheduleRequestIfSlaveIsAvailable): Deleted. * tools/js/database.js: * tools/js/os-build-fetcher.js: (prototype.async _reportCommits): * tools/js/privileged-api.js: (NodePrivilegedAPI.prototype.sendRequest): (NodePrivilegedAPI.configure): (NodePrivilegedAPI): * tools/pull-os-versions.py: (OSBuildFetcher.fetch_and_report_new_builds): * tools/run-analysis.js: (async analysisLoop): * tools/sync-buildbot.js: (syncLoop.const.makeTriggerable): (syncLoop): * tools/sync-commits.py: (Repository.fetch_commits_and_submit): * tools/sync-os-versions.js: (syncLoop): * tools/util.py: (submit_commits): * unit-tests/analysis-task-tests.js: * unit-tests/buildbot-syncer-tests.js: (sampleiOSConfig): (sampleBuildData): (async const): * unit-tests/checkconfig.js: * unit-tests/measurement-set-analyzer-tests.js: * unit-tests/privileged-api-tests.js: * unit-tests/retry-failed-build-requests-tests.js: * unit-tests/test-groups-tests.js: Canonical link: https://commits.webkit.org/235601@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274800 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-22 21:23:38 +00:00
server_config['worker']['name'], server_config['worker']['password'], ['OK', 'FailedToFindPreviousCommit'])
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
if result.get('status') == 'OK':
break
if result.get('status') == 'FailedToFindPreviousCommit':
previous_commit = self.fetch_commit(server_config, result['commit']['previousCommit'])
if not previous_commit:
raise Exception('Could not find the previous commit %s of %s' % (result['commit']['previousCommit'], result['commit']['revision']))
pending_commits = [previous_commit] + pending_commits
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
if result.get('status') != 'OK':
raise Exception(result)
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
print "Successfully submitted."
print
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
@abstractmethod
def fetch_next_commit(self, server_config, last_fetched):
pass
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
@abstractmethod
def fetch_commit(self, server_config, last_fetched):
pass
@abstractmethod
def format_revision(self, revision):
pass
def determine_last_reported_revision(self, server_config):
last_reported_revision = self.fetch_revision_from_dasbhoard(server_config, 'last-reported')
if last_reported_revision:
return last_reported_revision
def fetch_revision_from_dasbhoard(self, server_config, filter):
result = urllib2.urlopen(server_config['server']['url'] + '/api/commits/' + self._name + '/' + filter).read()
parsed_result = json.loads(result)
if parsed_result['status'] != 'OK' and parsed_result['status'] != 'RepositoryNotFound':
raise Exception(result)
commits = parsed_result.get('commits')
return commits[0]['revision'] if commits else None
class SVNRepository(Repository):
def __init__(self, name, svn_url, should_trust_certificate, use_server_auth, account_name_script_path):
assert not account_name_script_path or isinstance(account_name_script_path, list)
super(SVNRepository, self).__init__(name)
self._svn_url = svn_url
self._should_trust_certificate = should_trust_certificate
self._use_server_auth = use_server_auth
self._account_name_script_path = account_name_script_path
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
def fetch_next_commit(self, server_config, last_fetched):
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
if not last_fetched:
# FIXME: This is a problematic if dashboard can get results for revisions older than oldest_revision
# in the future because we never refetch older revisions.
last_fetched = self.fetch_revision_from_dasbhoard(server_config, 'oldest')
revision_to_fetch = int(last_fetched) + 1
args = ['svn', 'log', '--revision', str(revision_to_fetch), '--xml', self._svn_url, '--non-interactive']
if self._use_server_auth and 'auth' in server_config['server']:
server_auth = server_config['server']['auth']
args += ['--no-auth-cache', '--username', server_auth['username'], '--password', server_auth['password']]
if self._should_trust_certificate:
args += ['--trust-server-cert']
try:
output = subprocess.check_output(args, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as error:
if (': No such revision ' + str(revision_to_fetch)) in error.output:
return None
raise error
xml = parseXmlString(output)
time = text_content(xml.getElementsByTagName("date")[0])
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
author_elements = xml.getElementsByTagName("author")
author_account = text_content(author_elements[0]) if author_elements.length else None
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
message = text_content(xml.getElementsByTagName("msg")[0])
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
name = self._resolve_author_name(author_account) if author_account and self._account_name_script_path else None
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
result = {
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
'repository': self._name,
'revision': revision_to_fetch,
'time': time,
'message': message,
}
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
if author_account:
result['author'] = {'account': author_account, 'name': name}
return result
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
def _resolve_author_name(self, account):
try:
output = subprocess.check_output(self._account_name_script_path + [account])
except subprocess.CalledProcessError:
print 'Failed to resolve the name for account:', account
return None
match = Repository._name_account_compound_regex.match(output)
if match:
return match.group('name').strip('"')
return output.strip()
def format_revision(self, revision):
return 'r' + str(revision)
class GitRepository(Repository):
def __init__(self, name, git_checkout, git_url, git_branch=None, report_revision_identifier_in_commit_msg=False, report_svn_revison=False):
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
assert(os.path.isdir(git_checkout))
super(GitRepository, self).__init__(name)
self._git_checkout = git_checkout
self._git_url = git_url
self._git_branch = git_branch
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
self._tokenized_hashes = []
self._report_revision_identifier_in_commit_msg = report_revision_identifier_in_commit_msg
self._report_svn_revision = report_svn_revison
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
def fetch_next_commit(self, server_config, last_fetched):
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
if not last_fetched:
self._fetch_all_hashes()
tokens = self._tokenized_hashes[0]
else:
if self._report_svn_revision:
last_fetched_git_hash = self._git_hash_from_svn_revision(last_fetched)
if not last_fetched_git_hash:
self._fetch_remote()
last_fetched_git_hash = self._git_hash_from_svn_revision(last_fetched)
if not last_fetched_git_hash:
raise ValueError('Cannot find the git hash for the last fetched svn revision')
last_fetched = last_fetched_git_hash
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
tokens = self._find_next_hash(last_fetched)
if not tokens:
self._fetch_all_hashes()
tokens = self._find_next_hash(last_fetched)
if not tokens:
return None
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
return self._revision_from_tokens(tokens)
def fetch_commit(self, server_config, hash_to_find):
assert(self._tokenized_hashes)
for i, tokens in enumerate(self._tokenized_hashes):
if tokens and tokens[0] == hash_to_find:
return self._revision_from_tokens(tokens)
return None
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
def _svn_revision_from_git_hash(self, git_hash):
return self._run_git_command(['svn', 'find-rev', git_hash]).strip()
def _git_hash_from_svn_revision(self, revision):
return self._run_git_command(['svn', 'find-rev', 'r{}'.format(revision)]).strip()
Make sync-commits.py robust against missing Subversion authors and missing parent Git commits https://bugs.webkit.org/show_bug.cgi?id=167231 Reviewed by Antti Koivisto. Fixed a bug that a subversion commit that's missing author name (anonymous commit) results in an out of bound exception, and a bug that syncing a git repository starts failing once there was a merge commit which pulled in a commit data earlier than that of the last reported commit. For the latter fix, added --max-ancestor-fetch-count to specify the number of maximum commits to look back. * tools/sync-commits.py: (main): Added --max-ancestor-fetch-count. (Repository.fetch_commits_and_submit): If submit_commits fails with FailedToFindParentCommit, fetch the parent commit's information until we've resolved them all. (Repository.fetch_next_commit): Renamed from fetch_commit. (SVNRepository.fetch_next_commit): Renamed from fetch_commit. Don't try to get the author name if it's missing due to an anonymous commit. It's important to never include the "author" field in the JSON submitted to a dashboard since it rejects when "author" field is not an array (e.g. null). (GitRepository.fetch_next_commit): Renamed from fetch_commit. (GitRepository.fetch_commit): Added. Fetches the commit information for a given git hash. Used to retrieve missing parent commits. (GitRepository._revision_from_tokens): Extracted from fetch_commit. * tools/util.py: (submit_commits): Optionally takes status_to_accept to avoid throwing in the case of FailedToFindParentCommit and returns the response JSON. Canonical link: https://commits.webkit.org/184300@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210982 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-01-20 22:04:23 +00:00
def _revision_from_tokens(self, tokens):
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
current_hash = tokens[0]
commit_time = int(tokens[1])
author_email = tokens[2]
previous_hash = tokens[3] if len(tokens) >= 4 else None
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
author_name = self._run_git_command(['log', current_hash, '-1', '--pretty=%cn'])
message = self._run_git_command(['log', current_hash, '-1', '--pretty=%B'])
revision_identifier = None
if self._report_revision_identifier_in_commit_msg:
revision_identifier_match = REVISION_IDENTIFIER_RE.search(message)
if not revision_identifier_match:
raise ValueError('Expected commit message to include revision identifier, but cannot find it, will need a history rewrite to fix it')
revision_identifier = revision_identifier_match.group('revision_identifier')
current_revision = current_hash
previous_revision = previous_hash
if self._report_svn_revision:
current_revision = self._svn_revision_from_git_hash(current_hash)
if not current_revision:
raise ValueError('Cannot find SVN revison for {}'.format(current_hash))
if previous_hash:
previous_revision = self._svn_revision_from_git_hash(previous_hash)
if not previous_revision:
raise ValueError('Cannot find SVN revison for {}'.format(previous_hash))
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
return {
'repository': self._name,
'revision': current_revision,
'revisionIdentifier': revision_identifier,
'previousCommit': previous_revision,
'time': datetime.utcfromtimestamp(commit_time).strftime(r'%Y-%m-%dT%H:%M:%S.%f'),
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
'author': {'account': author_email, 'name': author_name},
'message': message,
}
def _find_next_hash(self, hash_to_find):
for i, tokens in enumerate(self._tokenized_hashes):
if tokens and tokens[0] == hash_to_find:
return self._tokenized_hashes[i + 1] if i + 1 < len(self._tokenized_hashes) else None
return None
def _fetch_remote(self):
if self._report_svn_revision:
self._run_git_command(['pull'])
subprocess.check_call(['rm', '-rf', os.path.join(self._git_checkout, '.git/svn')])
self._run_git_command(['svn', 'fetch'])
else:
self._run_git_command(['pull', self._git_url])
def _fetch_all_hashes(self):
self._fetch_remote()
scope = self._git_branch or '--all'
lines = self._run_git_command(['log', scope, '--date-order', '--reverse', '--pretty=%H %ct %ce %P']).split('\n')
Perf dashboard should have a script to sync git commits https://bugs.webkit.org/show_bug.cgi?id=157867 Reviewed by Chris Dumez. Added the support to pull from a Git repo to pull-svn.py and renamed it to sync-commits.py. Added two classes SVNRepository and GitRepository which inherits from an abstract class, Repository. The code that fetches commit and format revision number / git hash is specialized in each. * Install.md: * tools/pull-svn.py: Removed. * tools/sync-commits.py: Renamed from Websites/perf.webkit.org/tools/pull-svn.py. (main): Renamed --svn-config-json to --repository-config-json. Also made it robust against exceptions inside fetch_commits_and_submit of each Repository class. (load_repository): A factory function for SVNRepository and GitRepository. (Repository): Added. (Repository.__init__): Added. (Repository.fetch_commits_and_submit): Extracted from standalone fetch_commits_and_submit. (Repository.fetch_commit): Added. Implemented by a subclass. (Repository.format_revision): Ditto. (Repository.determine_last_reported_revision): Extracted from alonealone determine_first_revision_to_fetch. The fallback to use "oldest" has been moved to SVNRepository's fetch_commit since it doesn't work in Git. (Repository.fetch_revision_from_dasbhoard): Extracted from fetch_revision_from_dasbhoard. (SVNRepository): Added. (SVNRepository.__init__): Added. (SVNRepository.fetch_commit): Extracted from standalone fetch_commit_and_resolve_author and fetch_commit. (SVNRepository._resolve_author_name): Renamed from resolve_author_name_from_account. (SVNRepository.format_revision): Added. (GitRepository): Added. (GitRepository.__init__): (GitRepository.fetch_commit): Added. Fetches the list of all git hashes if needed, and finds the next hash. (GitRepository._find_next_hash): Added. Finds the first commit that appears after the specified hash. (GitRepository._fetch_all_hashes): Added. Gets the list of all git hashs chronologically (old to new). (GitRepository._run_git_command): Added. (GitRepository.format_revision): Added. Use the first 8 characters of the hash. Canonical link: https://commits.webkit.org/175993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@201115 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-18 23:42:39 +00:00
self._tokenized_hashes = [line.split() for line in lines]
def _run_git_command(self, args):
return subprocess.check_output(['git', '-C', self._git_checkout] + args, stderr=subprocess.STDOUT)
def format_revision(self, revision):
return str(revision)[0:8]
if __name__ == "__main__":
main(sys.argv)