Example #1
0
    def scm(self):
        # Lazily initialize SCM to not error-out before command line parsing (or when running non-scm commands).
        original_cwd = os.path.abspath(".")
        if not self._scm:
            self._scm = detect_scm_system(original_cwd)

        if not self._scm:
            script_directory = os.path.abspath(sys.path[0])
            self._scm = detect_scm_system(script_directory)
            if self._scm:
                log("The current directory (%s) is not a WebKit checkout, using %s" % (original_cwd, self._scm.checkout_root))
            else:
                error("FATAL: Failed to determine the SCM system for either %s or %s" % (original_cwd, script_directory))

        return self._scm
Example #2
0
    def test_create_binary_patch(self):
        # Create a git binary patch and check the contents.
        scm = detect_scm_system(self.git_checkout_path)
        test_file_name = 'binary_file'
        test_file_path = os.path.join(self.git_checkout_path, test_file_name)
        file_contents = ''.join(map(chr, range(256)))
        write_into_file_at_path(test_file_path, file_contents, encoding=None)
        run_command(['git', 'add', test_file_name])
        patch = scm.create_patch()
        self.assertTrue(re.search(r'\nliteral 0\n', patch))
        self.assertTrue(re.search(r'\nliteral 256\n', patch))

        # Check if we can apply the created patch.
        run_command(['git', 'rm', '-f', test_file_name])
        self._setup_webkittools_scripts_symlink(scm)
        self.checkout.apply_patch(self._create_patch(patch))
        self.assertEqual(file_contents, read_from_path(test_file_path, encoding=None))

        # Check if we can create a patch from a local commit.
        write_into_file_at_path(test_file_path, file_contents, encoding=None)
        run_command(['git', 'add', test_file_name])
        run_command(['git', 'commit', '-m', 'binary diff'])
        patch_from_local_commit = scm.create_patch('HEAD')
        self.assertTrue(re.search(r'\nliteral 0\n', patch_from_local_commit))
        self.assertTrue(re.search(r'\nliteral 256\n', patch_from_local_commit))
Example #3
0
    def test_create_binary_patch(self):
        # Create a git binary patch and check the contents.
        scm = detect_scm_system(self.git_checkout_path)
        test_file_name = 'binary_file'
        test_file_path = os.path.join(self.git_checkout_path, test_file_name)
        file_contents = ''.join(map(chr, range(256)))
        write_into_file_at_path(test_file_path, file_contents, encoding=None)
        run_command(['git', 'add', test_file_name])
        patch = scm.create_patch()
        self.assertTrue(re.search(r'\nliteral 0\n', patch))
        self.assertTrue(re.search(r'\nliteral 256\n', patch))

        # Check if we can apply the created patch.
        run_command(['git', 'rm', '-f', test_file_name])
        self._setup_webkittools_scripts_symlink(scm)
        self.checkout.apply_patch(self._create_patch(patch))
        self.assertEqual(file_contents,
                         read_from_path(test_file_path, encoding=None))

        # Check if we can create a patch from a local commit.
        write_into_file_at_path(test_file_path, file_contents, encoding=None)
        run_command(['git', 'add', test_file_name])
        run_command(['git', 'commit', '-m', 'binary diff'])
        patch_from_local_commit = scm.create_patch('HEAD')
        self.assertTrue(re.search(r'\nliteral 0\n', patch_from_local_commit))
        self.assertTrue(re.search(r'\nliteral 256\n', patch_from_local_commit))
Example #4
0
 def test_create_patch_git_commit_range(self):
     self._three_local_commits()
     scm = detect_scm_system(self.git_checkout_path)
     patch = scm.create_patch(git_commit="HEAD~2..HEAD")
     self.assertFalse(re.search(r'test_file_commit0', patch))
     self.assertTrue(re.search(r'test_file_commit2', patch))
     self.assertTrue(re.search(r'test_file_commit1', patch))
Example #5
0
 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)
Example #6
0
 def _setup_webkittools_scripts_symlink(self, local_scm):
     webkit_scm = detect_scm_system(
         os.path.dirname(os.path.abspath(__file__)))
     webkit_scripts_directory = webkit_scm.scripts_directory()
     local_scripts_directory = local_scm.scripts_directory()
     os.mkdir(os.path.dirname(local_scripts_directory))
     os.symlink(webkit_scripts_directory, local_scripts_directory)
Example #7
0
    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()
Example #8
0
 def test_changed_files_multiple_local_commits_no_squash(self):
     self._two_local_commits()
     scm = detect_scm_system(self.git_checkout_path)
     files = scm.changed_files(squash=False)
     # FIXME: It's weird that with squash=False, create_patch/changed_files ignores local commits,
     # but commit_with_message commits them.
     self.assertTrue(len(files) == 0)
Example #9
0
    def test_create_patch_is_full_patch(self):
        test_dir_path = os.path.join(self.svn_checkout_path, "test_dir2")
        os.mkdir(test_dir_path)
        test_file_path = os.path.join(test_dir_path, 'test_file2')
        write_into_file_at_path(test_file_path, 'test content')
        run_command(['svn', 'add', 'test_dir2'])

        # create_patch depends on 'svn-create-patch', so make a dummy version.
        scripts_path = os.path.join(self.svn_checkout_path, 'WebKitTools',
                                    'Scripts')
        os.makedirs(scripts_path)
        create_patch_path = os.path.join(scripts_path, 'svn-create-patch')
        write_into_file_at_path(
            create_patch_path, '#!/bin/sh\necho $PWD'
        )  # We could pass -n to prevent the \n, but not all echo accept -n.
        os.chmod(create_patch_path, stat.S_IXUSR | stat.S_IRUSR)

        # Change into our test directory and run the create_patch command.
        os.chdir(test_dir_path)
        scm = detect_scm_system(test_dir_path)
        self.assertEqual(scm.checkout_root, self.svn_checkout_path
                         )  # Sanity check that detection worked right.
        patch_contents = scm.create_patch()
        # Our fake 'svn-create-patch' returns $PWD instead of a patch, check that it was executed from the root of the repo.
        self.assertEqual("%s\n" % os.path.realpath(scm.checkout_root),
                         patch_contents)  # Add a \n because echo adds a \n.
Example #10
0
    def tear_down(cls, test_object):
        run_command(['rm', '-rf', test_object.svn_repo_path])
        run_command(['rm', '-rf', test_object.svn_checkout_path])

        # Now that we've deleted the checkout paths, cwddir may be invalid
        # Change back to a valid directory so that later calls to os.getcwd() do not fail.
        os.chdir(detect_scm_system(os.path.dirname(__file__)).checkout_root)
Example #11
0
 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)
Example #12
0
 def test_changed_files_git_commit_range(self):
     self._three_local_commits()
     scm = detect_scm_system(self.git_checkout_path)
     files = scm.changed_files(git_commit="HEAD~2..HEAD")
     self.assertTrue('test_file_commit0' not in files)
     self.assertTrue('test_file_commit1' in files)
     self.assertTrue('test_file_commit2' in files)
Example #13
0
    def tear_down(cls, test_object):
        run_command(['rm', '-rf', test_object.svn_repo_path])
        run_command(['rm', '-rf', test_object.svn_checkout_path])

        # Now that we've deleted the checkout paths, cwddir may be invalid
        # Change back to a valid directory so that later calls to os.getcwd() do not fail.
        os.chdir(detect_scm_system(os.path.dirname(__file__)).checkout_root)
Example #14
0
 def test_create_patch_multiple_local_commits_no_squash(self):
     self._two_local_commits()
     scm = detect_scm_system(self.git_checkout_path)
     patch = scm.create_patch(squash=False)
     # FIXME: It's weird that with squash=False, create_patch/changed_files ignores local commits,
     # but commit_with_message commits them.
     self.assertTrue(patch == "")
Example #15
0
 def test_not_have_authorization_for_realm(self):
     scm = detect_scm_system(self.svn_checkout_path)
     fake_home_dir = tempfile.mkdtemp(suffix="fake_home_dir")
     svn_config_dir_path = os.path.join(fake_home_dir, ".subversion")
     os.mkdir(svn_config_dir_path)
     self.assertFalse(scm.has_authorization_for_realm(home_directory=fake_home_dir))
     os.rmdir(svn_config_dir_path)
     os.rmdir(fake_home_dir)
Example #16
0
 def test_apply_git_patch_force(self):
     scm = detect_scm_system(self.git_checkout_path)
     patch = self._create_patch(_git_diff('HEAD~2..HEAD'))
     self._setup_webkittools_scripts_symlink(scm)
     self.assertRaises(ScriptError,
                       Checkout(scm).apply_patch,
                       patch,
                       force=True)
Example #17
0
 def test_apply_git_patch(self):
     scm = detect_scm_system(self.git_checkout_path)
     # We carefullly pick a diff which does not have a directory addition
     # as currently svn-apply will error out when trying to remove directories
     # in Git: https://bugs.webkit.org/show_bug.cgi?id=34871
     patch = self._create_patch(_git_diff('HEAD..HEAD^'))
     self._setup_webkittools_scripts_symlink(scm)
     Checkout(scm).apply_patch(patch)
Example #18
0
    def setUp(self):
        self.original_dir = os.getcwd()

        SVNTestRepository.setup(self)
        self._setup_git_checkout()
        self.scm = detect_scm_system(self.git_checkout_path)
        # For historical reasons, we test some checkout code here too.
        self.checkout = Checkout(self.scm)
Example #19
0
 def test_apply_svn_patch_force(self):
     scm = detect_scm_system(self.svn_checkout_path)
     patch = self._create_patch(_svn_diff("-r3:5"))
     self._setup_webkittools_scripts_symlink(scm)
     self.assertRaises(ScriptError,
                       Checkout(scm).apply_patch,
                       patch,
                       force=True)
Example #20
0
 def test_apply_git_patch(self):
     scm = detect_scm_system(self.git_checkout_path)
     # We carefullly pick a diff which does not have a directory addition
     # as currently svn-apply will error out when trying to remove directories
     # in Git: https://bugs.webkit.org/show_bug.cgi?id=34871
     patch = self._create_patch(_git_diff('HEAD..HEAD^'))
     self._setup_webkittools_scripts_symlink(scm)
     Checkout(scm).apply_patch(patch)
Example #21
0
    def test_commit_with_message_working_copy_only(self):
        write_into_file_at_path('test_file_commit1', 'more test content')
        run_command(['git', 'add', 'test_file_commit1'])
        scm = detect_scm_system(self.git_checkout_path)
        commit_text = scm.commit_with_message("yet another test commit")

        self.assertEqual(scm.svn_revision_from_commit_text(commit_text), '6')
        svn_log = run_command(['git', 'svn', 'log', '--limit=1', '--verbose'])
        self.assertTrue(re.search(r'test_file_commit1', svn_log))
Example #22
0
 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)
     self.assertEqual(len(scm.commit_ids_from_commitish_arguments(['HEAD', 'HEAD~2'])), 2)
 
     # ... is an invalid range specifier
     self.assertRaises(ScriptError, scm.commit_ids_from_commitish_arguments, ['trunk...HEAD'])
Example #23
0
 def test_not_have_authorization_for_realm(self):
     scm = detect_scm_system(self.svn_checkout_path)
     fake_home_dir = tempfile.mkdtemp(suffix="fake_home_dir")
     svn_config_dir_path = os.path.join(fake_home_dir, ".subversion")
     os.mkdir(svn_config_dir_path)
     self.assertFalse(
         scm.has_authorization_for_realm(home_directory=fake_home_dir))
     os.rmdir(svn_config_dir_path)
     os.rmdir(fake_home_dir)
Example #24
0
    def test_commit_with_message_working_copy_only(self):
        write_into_file_at_path('test_file_commit1', 'more test content')
        run_command(['git', 'add', 'test_file_commit1'])
        scm = detect_scm_system(self.git_checkout_path)
        commit_text = scm.commit_with_message("yet another test commit")

        self.assertEqual(scm.svn_revision_from_commit_text(commit_text), '6')
        svn_log = run_command(['git', 'svn', 'log', '--limit=1', '--verbose'])
        self.assertTrue(re.search(r'test_file_commit1', svn_log))
Example #25
0
    def setUp(self):
        """Sets up fresh git repository with one commit. Then setups a second git
        repo that tracks the first one."""
        self.original_dir = os.getcwd()

        self.untracking_checkout_path = tempfile.mkdtemp(suffix="git_test_checkout2")
        run_command(['git', 'init', self.untracking_checkout_path])

        os.chdir(self.untracking_checkout_path)
        write_into_file_at_path('foo_file', 'foo')
        run_command(['git', 'add', 'foo_file'])
        run_command(['git', 'commit', '-am', 'dummy commit'])
        self.untracking_scm = detect_scm_system(self.untracking_checkout_path)

        self.tracking_git_checkout_path = tempfile.mkdtemp(suffix="git_test_checkout")
        run_command(['git', 'clone', '--quiet', self.untracking_checkout_path, self.tracking_git_checkout_path])
        os.chdir(self.tracking_git_checkout_path)
        self.tracking_scm = detect_scm_system(self.tracking_git_checkout_path)
Example #26
0
    def test_commit_with_message_multiple_local_commits_squash(self):
        self._two_local_commits()
        scm = detect_scm_system(self.git_checkout_path)
        commit_text = scm.commit_with_message("yet another test commit", squash=True)
        self.assertEqual(scm.svn_revision_from_commit_text(commit_text), '6')

        svn_log = run_command(['git', 'svn', 'log', '--limit=1', '--verbose'])
        self.assertTrue(re.search(r'test_file_commit2', svn_log))
        self.assertTrue(re.search(r'test_file_commit1', svn_log))
Example #27
0
    def scm(self):
        # Lazily initialize SCM to not error-out before command line parsing (or when running non-scm commands).
        original_cwd = os.path.abspath(".")
        if not self._scm:
            self._scm = detect_scm_system(original_cwd)

        if not self._scm:
            script_directory = os.path.abspath(sys.path[0])
            self._scm = detect_scm_system(script_directory)
            if self._scm:
                log("The current directory (%s) is not a WebKit checkout, using %s"
                    % (original_cwd, self._scm.checkout_root))
            else:
                error(
                    "FATAL: Failed to determine the SCM system for either %s or %s"
                    % (original_cwd, script_directory))

        return self._scm
Example #28
0
    def test_commitish_order(self):
        scm = detect_scm_system(self.git_checkout_path)

        commit_range = 'HEAD~3..HEAD'

        actual_commits = scm.commit_ids_from_commitish_arguments([commit_range])
        expected_commits = []
        expected_commits += reversed(run_command(['git', 'rev-list', commit_range]).splitlines())

        self.assertEqual(actual_commits, expected_commits)
Example #29
0
    def test_commit_with_message_multiple_local_commits_squash(self):
        self._two_local_commits()
        scm = detect_scm_system(self.git_checkout_path)
        commit_text = scm.commit_with_message("yet another test commit",
                                              squash=True)
        self.assertEqual(scm.svn_revision_from_commit_text(commit_text), '6')

        svn_log = run_command(['git', 'svn', 'log', '--limit=1', '--verbose'])
        self.assertTrue(re.search(r'test_file_commit2', svn_log))
        self.assertTrue(re.search(r'test_file_commit1', svn_log))
def default_out_dir():
    current_scm = scm.detect_scm_system(os.path.dirname(sys.argv[0]))
    if not current_scm:
        return os.getcwd()
    root_dir = current_scm.checkout_root
    if not root_dir:
        return os.getcwd()
    out_dir = os.path.join(root_dir, "LayoutTests/fast/canvas/webgl")
    if os.path.isdir(out_dir):
        return out_dir
    return os.getcwd()
def default_out_dir():
    current_scm = scm.detect_scm_system(os.path.dirname(sys.argv[0]))
    if not current_scm:
        return os.getcwd()
    root_dir = current_scm.checkout_root
    if not root_dir:
        return os.getcwd()
    out_dir = os.path.join(root_dir, "LayoutTests/fast/canvas/webgl")
    if os.path.isdir(out_dir):
        return out_dir
    return os.getcwd()
Example #32
0
 def test_has_authorization_for_realm(self):
     scm = detect_scm_system(self.svn_checkout_path)
     fake_home_dir = tempfile.mkdtemp(suffix="fake_home_dir")
     svn_config_dir_path = os.path.join(fake_home_dir, ".subversion")
     os.mkdir(svn_config_dir_path)
     fake_webkit_auth_file = os.path.join(svn_config_dir_path, "fake_webkit_auth_file")
     write_into_file_at_path(fake_webkit_auth_file, SVN.svn_server_realm)
     self.assertTrue(scm.has_authorization_for_realm(home_directory=fake_home_dir))
     os.remove(fake_webkit_auth_file)
     os.rmdir(svn_config_dir_path)
     os.rmdir(fake_home_dir)
Example #33
0
    def test_commit_with_message_git_commit_range(self):
        self._three_local_commits()

        scm = detect_scm_system(self.git_checkout_path)
        commit_text = scm.commit_with_message("another test commit", git_commit="HEAD~2..HEAD")
        self.assertEqual(scm.svn_revision_from_commit_text(commit_text), '6')

        svn_log = run_command(['git', 'svn', 'log', '--limit=1', '--verbose'])
        self.assertFalse(re.search(r'test_file_commit0', svn_log))
        self.assertTrue(re.search(r'test_file_commit1', svn_log))
        self.assertTrue(re.search(r'test_file_commit2', svn_log))
Example #34
0
    def test_commitish_order(self):
        scm = detect_scm_system(self.git_checkout_path)

        commit_range = 'HEAD~3..HEAD'

        actual_commits = scm.commit_ids_from_commitish_arguments(
            [commit_range])
        expected_commits = []
        expected_commits += reversed(
            run_command(['git', 'rev-list', commit_range]).splitlines())

        self.assertEqual(actual_commits, expected_commits)
Example #35
0
    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)
        self.assertEqual(
            len(scm.commit_ids_from_commitish_arguments(['HEAD', 'HEAD~2'])),
            2)

        # ... is an invalid range specifier
        self.assertRaises(ScriptError, scm.commit_ids_from_commitish_arguments,
                          ['trunk...HEAD'])
Example #36
0
 def test_has_authorization_for_realm(self):
     scm = detect_scm_system(self.svn_checkout_path)
     fake_home_dir = tempfile.mkdtemp(suffix="fake_home_dir")
     svn_config_dir_path = os.path.join(fake_home_dir, ".subversion")
     os.mkdir(svn_config_dir_path)
     fake_webkit_auth_file = os.path.join(svn_config_dir_path,
                                          "fake_webkit_auth_file")
     write_into_file_at_path(fake_webkit_auth_file, SVN.svn_server_realm)
     self.assertTrue(
         scm.has_authorization_for_realm(home_directory=fake_home_dir))
     os.remove(fake_webkit_auth_file)
     os.rmdir(svn_config_dir_path)
     os.rmdir(fake_home_dir)
Example #37
0
    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()
Example #38
0
    def test_create_patch_is_full_patch(self):
        test_dir_path = os.path.join(self.svn_checkout_path, "test_dir2")
        os.mkdir(test_dir_path)
        test_file_path = os.path.join(test_dir_path, 'test_file2')
        write_into_file_at_path(test_file_path, 'test content')
        run_command(['svn', 'add', 'test_dir2'])

        # create_patch depends on 'svn-create-patch', so make a dummy version.
        scripts_path = os.path.join(self.svn_checkout_path, 'WebKitTools', 'Scripts')
        os.makedirs(scripts_path)
        create_patch_path = os.path.join(scripts_path, 'svn-create-patch')
        write_into_file_at_path(create_patch_path, '#!/bin/sh\necho $PWD') # We could pass -n to prevent the \n, but not all echo accept -n.
        os.chmod(create_patch_path, stat.S_IXUSR | stat.S_IRUSR)

        # Change into our test directory and run the create_patch command.
        os.chdir(test_dir_path)
        scm = detect_scm_system(test_dir_path)
        self.assertEqual(scm.checkout_root, self.svn_checkout_path) # Sanity check that detection worked right.
        patch_contents = scm.create_patch()
        # Our fake 'svn-create-patch' returns $PWD instead of a patch, check that it was executed from the root of the repo.
        self.assertEqual("%s\n" % os.path.realpath(scm.checkout_root), patch_contents) # Add a \n because echo adds a \n.
Example #39
0
 def test_detection(self):
     scm = detect_scm_system(self.svn_checkout_path)
     self.assertEqual(scm.display_name(), "svn")
     self.assertEqual(scm.supports_local_commits(), False)
Example #40
0
 def test_apply_git_patch_force(self):
     scm = detect_scm_system(self.git_checkout_path)
     patch = self._create_patch(_git_diff('HEAD~2..HEAD'))
     self._setup_webkittools_scripts_symlink(scm)
     self.assertRaises(ScriptError, Checkout(scm).apply_patch, patch, force=True)
Example #41
0
 def test_apply_svn_patch(self):
     scm = detect_scm_system(self.svn_checkout_path)
     patch = self._create_patch(_svn_diff("-r5:4"))
     self._setup_webkittools_scripts_symlink(scm)
     Checkout(scm).apply_patch(patch)
Example #42
0
 def test_changed_files_not_squashed(self):
     self._one_local_commit_plus_working_copy_changes()
     scm = detect_scm_system(self.git_checkout_path)
     files = scm.changed_files(squash=False)
     self.assertTrue('test_file_commit2' in files)
     self.assertFalse('test_file_commit1' in files)
Example #43
0
 def test_create_patch_local_plus_working_copy(self):
     self._one_local_commit_plus_working_copy_changes()
     scm = detect_scm_system(self.git_checkout_path)
     self.assertRaises(ScriptError, scm.create_patch)
Example #44
0
 def test_detect_scm_system_relative_url(self):
     scm = detect_scm_system(".")
     # I wanted to assert that we got the right path, but there was some
     # crazy magic with temp folder names that I couldn't figure out.
     self.assertTrue(scm.checkout_root)
Example #45
0
 def test_commit_with_message_multiple_local_commits(self):
     self._two_local_commits()
     scm = detect_scm_system(self.git_checkout_path)
     self.assertRaises(ScriptError, scm.commit_with_message, ["another test commit"])
Example #46
0
 def test_create_patch_local_plus_working_copy(self):
     self._one_local_commit_plus_working_copy_changes()
     scm = detect_scm_system(self.git_checkout_path)
     self.assertRaises(ScriptError, scm.create_patch)
Example #47
0
 def test_commit_with_message_multiple_local_commits(self):
     self._two_local_commits()
     scm = detect_scm_system(self.git_checkout_path)
     self.assertRaises(ScriptError, scm.commit_with_message,
                       ["another test commit"])
Example #48
0
 def test_commit_with_message_git_commit_and_working_copy(self):
     self._two_local_commits()
     write_into_file_at_path('test_file_commit1', 'working copy change')
     scm = detect_scm_system(self.git_checkout_path)
     self.assertRaises(ScriptError, scm.commit_with_message,
                       ["another test commit", 'git_commit="HEAD^"'])
Example #49
0
 def test_commit_with_message_git_commit_and_working_copy(self):
     self._two_local_commits()
     write_into_file_at_path('test_file_commit1', 'working copy change')
     scm = detect_scm_system(self.git_checkout_path)
     self.assertRaises(ScriptError, scm.commit_with_message, ["another test commit", 'git_commit="HEAD^"'])
Example #50
0
 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)
Example #51
0
 def test_commit_with_message_not_synced_squash(self):
     run_command(['git', 'checkout', '-b', 'my-branch', 'trunk~3'])
     self._two_local_commits()
     scm = detect_scm_system(self.git_checkout_path)
     self.assertRaises(ScriptError, scm.commit_with_message, "another test commit", squash=True)
Example #52
0
 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)
Example #53
0
 def test_create_patch_multiple_local_commits(self):
     self._two_local_commits()
     scm = detect_scm_system(self.git_checkout_path)
     self.assertRaises(ScriptError, scm.create_patch)
Example #54
0
 def test_create_patch_not_squashed(self):
     self._one_local_commit_plus_working_copy_changes()
     scm = detect_scm_system(self.git_checkout_path)
     patch = scm.create_patch(squash=False)
     self.assertTrue(re.search(r'test_file_commit2', patch))
     self.assertFalse(re.search(r'test_file_commit1', patch))
Example #55
0
 def test_create_patch_not_synced_squash(self):
     run_command(['git', 'checkout', '-b', 'my-branch', 'trunk~3'])
     self._two_local_commits()
     scm = detect_scm_system(self.git_checkout_path)
     self.assertRaises(ScriptError, scm.create_patch, squash=True)
Example #56
0
 def test_changed_files_multiple_local_commits_squash(self):
     self._two_local_commits()
     scm = detect_scm_system(self.git_checkout_path)
     files = scm.changed_files(squash=True)
     self.assertTrue('test_file_commit2' in files)
     self.assertTrue('test_file_commit1' in files)
Example #57
0
 def test_create_patch_multiple_local_commits_squash(self):
     self._two_local_commits()
     scm = detect_scm_system(self.git_checkout_path)
     patch = scm.create_patch(squash=True)
     self.assertTrue(re.search(r'test_file_commit2', patch))
     self.assertTrue(re.search(r'test_file_commit1', patch))
Example #58
0
 def test_changed_files_multiple_local_commits(self):
     self._two_local_commits()
     scm = detect_scm_system(self.git_checkout_path)
     self.assertRaises(ScriptError, scm.changed_files)
def detect_checkout():
    """Return a WebKitCheckout instance, or None if it cannot be found."""
    cwd = os.path.abspath(os.curdir)
    scm = detect_scm_system(cwd)

    return None if scm is None else WebKitCheckout(scm)
Example #60
0
 def test_changed_files_git_commit_range(self):
     self._two_local_commits()
     scm = detect_scm_system(self.git_checkout_path)
     files = scm.changed_files(git_commit="HEAD~2..HEAD")
     self.assertTrue('test_file_commit1' in files)
     self.assertTrue('test_file_commit2' in files)