本文整理匯總了Python中webkitpy.common.checkout.api.Checkout類的典型用法代碼示例。如果您正苦於以下問題:Python Checkout類的具體用法?Python Checkout怎麽用?Python Checkout使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Checkout類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_modified_changelogs
def test_modified_changelogs(self):
scm = Mock()
scm.checkout_root = "/foo/bar"
scm.changed_files = lambda git_commit: ["file1", "ChangeLog", "relative/path/ChangeLog"]
checkout = Checkout(scm)
expected_changlogs = ["/foo/bar/ChangeLog", "/foo/bar/relative/path/ChangeLog"]
self.assertEqual(checkout.modified_changelogs(git_commit=None), expected_changlogs)
示例2: test_commit_message_for_this_commit
def test_commit_message_for_this_commit(self):
checkout = Checkout(None)
checkout.modified_changelogs = lambda: ["ChangeLog1", "ChangeLog2"]
output = OutputCapture()
expected_stderr = "Parsing ChangeLog: ChangeLog1\nParsing ChangeLog: ChangeLog2\n"
commit_message = output.assert_outputs(self, checkout.commit_message_for_this_commit, expected_stderr=expected_stderr)
self.assertEqual(commit_message.message(), self.expected_commit_message)
示例3: test_latest_entry_for_changelog_at_revision
def test_latest_entry_for_changelog_at_revision(self):
scm = Mock()
def mock_contents_at_revision(changelog_path, revision):
self.assertEqual(changelog_path, "foo")
self.assertEqual(revision, "bar")
return _changelog1
scm.contents_at_revision = mock_contents_at_revision
checkout = Checkout(scm)
entry = checkout._latest_entry_for_changelog_at_revision("foo", "bar")
self.assertEqual(entry.contents(), _changelog1entry1)
示例4: test_latest_entry_for_changelog_at_revision
def test_latest_entry_for_changelog_at_revision(self):
scm = Mock()
def mock_contents_at_revision(changelog_path, revision):
self.assertEqual(changelog_path, "foo")
self.assertEqual(revision, "bar")
# contents_at_revision is expected to return a byte array (str)
# so we encode our unicode ChangeLog down to a utf-8 stream.
return _changelog1.encode("utf-8")
scm.contents_at_revision = mock_contents_at_revision
checkout = Checkout(scm)
entry = checkout._latest_entry_for_changelog_at_revision("foo", "bar")
self.assertEqual(entry.contents(), _changelog1entry1)
示例5: test_commit_info_for_revision
def test_commit_info_for_revision(self):
scm = Mock()
scm.committer_email_for_revision = lambda revision: "[email protected]"
checkout = Checkout(scm)
checkout.changelog_entries_for_revision = lambda revision: [ChangeLogEntry(_changelog1entry1)]
commitinfo = checkout.commit_info_for_revision(4)
self.assertEqual(commitinfo.bug_id(), 36629)
self.assertEqual(commitinfo.author_name(), "Eric Seidel")
self.assertEqual(commitinfo.author_email(), "[email protected]")
self.assertEqual(commitinfo.reviewer_text(), None)
self.assertEqual(commitinfo.reviewer(), None)
self.assertEqual(commitinfo.committer_email(), "[email protected]")
self.assertEqual(commitinfo.committer(), None)
示例6: setUp
def setUp(self):
SVNTestRepository.setup(self)
self._setup_git_clone_of_svn_repository()
os.chdir(self.git_checkout_path)
self.scm = detect_scm_system(self.git_checkout_path)
# For historical reasons, we test some checkout code here too.
self.checkout = Checkout(self.scm)
示例7: test_suggested_reviewers
def test_suggested_reviewers(self):
def mock_changelog_entries_for_revision(revision):
if revision % 2 == 0:
return [ChangeLogEntry(_changelog1entry1)]
return [ChangeLogEntry(_changelog1entry2)]
def mock_revisions_changing_file(path, limit=5):
if path.endswith("ChangeLog"):
return [3]
return [4, 8]
scm = Mock()
scm.checkout_root = "/foo/bar"
scm.changed_files = lambda git_commit: ["file1", "file2", "relative/path/ChangeLog"]
scm.revisions_changing_file = mock_revisions_changing_file
checkout = Checkout(scm)
checkout.changelog_entries_for_revision = mock_changelog_entries_for_revision
reviewers = checkout.suggested_reviewers(git_commit=None)
reviewer_names = [reviewer.full_name for reviewer in reviewers]
self.assertEqual(reviewer_names, [u'Tor Arne Vestb\xf8'])
示例8: test_bug_id_for_this_commit
def test_bug_id_for_this_commit(self):
scm = Mock()
checkout = Checkout(scm)
checkout.commit_message_for_this_commit = lambda git_commit, changed_files=None: CommitMessage(ChangeLogEntry(_changelog1entry1).contents().splitlines())
self.assertEqual(checkout.bug_id_for_this_commit(git_commit=None), 36629)
示例9: test_bug_id_for_revision
def test_bug_id_for_revision(self):
scm = Mock()
scm.committer_email_for_revision = lambda revision: "[email protected]"
checkout = Checkout(scm)
checkout.changelog_entries_for_revision = lambda revision: [ChangeLogEntry(_changelog1entry1)]
self.assertEqual(checkout.bug_id_for_revision(4), 36629)
示例10: GitTest
class GitTest(SCMTest):
def _setup_git_clone_of_svn_repository(self):
self.git_checkout_path = tempfile.mkdtemp(suffix="git_test_checkout")
# --quiet doesn't make git svn silent, so we use run_silent to redirect output
run_silent(['git', 'svn', '--quiet', 'clone', self.svn_repo_url, self.git_checkout_path])
def _tear_down_git_clone_of_svn_repository(self):
run_command(['rm', '-rf', self.git_checkout_path])
def setUp(self):
SVNTestRepository.setup(self)
self._setup_git_clone_of_svn_repository()
os.chdir(self.git_checkout_path)
self.scm = detect_scm_system(self.git_checkout_path)
# For historical reasons, we test some checkout code here too.
self.checkout = Checkout(self.scm)
def tearDown(self):
SVNTestRepository.tear_down(self)
self._tear_down_git_clone_of_svn_repository()
def test_detection(self):
scm = detect_scm_system(self.git_checkout_path)
self.assertEqual(scm.display_name(), "git")
self.assertEqual(scm.supports_local_commits(), True)
def test_read_git_config(self):
key = 'test.git-config'
value = 'git-config value'
run_command(['git', 'config', key, value])
self.assertEqual(self.scm.read_git_config(key), value)
def test_local_commits(self):
test_file = os.path.join(self.git_checkout_path, 'test_file')
write_into_file_at_path(test_file, 'foo')
run_command(['git', 'commit', '-a', '-m', 'local commit'])
self.assertEqual(len(self.scm.local_commits()), 1)
def test_discard_local_commits(self):
test_file = os.path.join(self.git_checkout_path, 'test_file')
write_into_file_at_path(test_file, 'foo')
run_command(['git', 'commit', '-a', '-m', 'local commit'])
self.assertEqual(len(self.scm.local_commits()), 1)
self.scm.discard_local_commits()
self.assertEqual(len(self.scm.local_commits()), 0)
def test_delete_branch(self):
old_branch = run_command(['git', 'symbolic-ref', 'HEAD']).strip()
new_branch = 'foo'
run_command(['git', 'checkout', '-b', new_branch])
self.assertEqual(run_command(['git', 'symbolic-ref', 'HEAD']).strip(), 'refs/heads/' + new_branch)
run_command(['git', 'checkout', old_branch])
self.scm.delete_branch(new_branch)
self.assertFalse(re.search(r'foo', run_command(['git', 'branch'])))
def test_svn_merge_base(self):
# Diff to merge-base should include working-copy changes,
# which the diff to svn_branch.. doesn't.
test_file = os.path.join(self.git_checkout_path, 'test_file')
write_into_file_at_path(test_file, 'foo')
diff_to_common_base = run_command(['git', 'diff', self.scm.svn_branch_name() + '..'])
diff_to_merge_base = run_command(['git', 'diff', self.scm.svn_merge_base()])
self.assertFalse(re.search(r'foo', diff_to_common_base))
self.assertTrue(re.search(r'foo', diff_to_merge_base))
def test_rebase_in_progress(self):
svn_test_file = os.path.join(self.svn_checkout_path, 'test_file')
write_into_file_at_path(svn_test_file, "svn_checkout")
run_command(['svn', 'commit', '--message', 'commit to conflict with git commit'], cwd=self.svn_checkout_path)
git_test_file = os.path.join(self.git_checkout_path, 'test_file')
write_into_file_at_path(git_test_file, "git_checkout")
run_command(['git', 'commit', '-a', '-m', 'commit to be thrown away by rebase abort'])
# --quiet doesn't make git svn silent, so use run_silent to redirect output
self.assertRaises(ScriptError, run_silent, ['git', 'svn', '--quiet', 'rebase']) # Will fail due to a conflict leaving us mid-rebase.
scm = detect_scm_system(self.git_checkout_path)
self.assertTrue(scm.rebase_in_progress())
# Make sure our cleanup works.
scm.clean_working_directory()
self.assertFalse(scm.rebase_in_progress())
# Make sure cleanup doesn't throw when no rebase is in progress.
scm.clean_working_directory()
def test_commitish_parsing(self):
scm = detect_scm_system(self.git_checkout_path)
# Multiple revisions are cherry-picked.
self.assertEqual(len(scm.commit_ids_from_commitish_arguments(['HEAD~2'])), 1)
#.........這裏部分代碼省略.........