Example #1
0
    def test_create_patch_is_full_patch(self):
        test_dir_path = os.path.join(self.svn_checkout_path, 'test_dir')
        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_dir'])

        # 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 #2
0
    def test_run_command_with_pipe(self):
        input_process = subprocess.Popen(['echo', 'foo\nbar'],
                                         stdout=subprocess.PIPE,
                                         stderr=self.dev_null)
        self.assertEqual(
            run_command(['grep', 'bar'], input=input_process.stdout), "bar\n")

        # Test the non-pipe case too:
        self.assertEqual(run_command(['grep', 'bar'], input="foo\nbar"),
                         "bar\n")

        command_returns_non_zero = ['/bin/sh', '--invalid-option']
        # Test when the input pipe process fails.
        input_process = subprocess.Popen(command_returns_non_zero,
                                         stdout=subprocess.PIPE,
                                         stderr=self.dev_null)
        self.assertTrue(input_process.poll() != 0)
        self.assertRaises(ScriptError,
                          run_command, ['grep', 'bar'],
                          input=input_process.stdout)

        # Test when the run_command process fails.
        input_process = subprocess.Popen(
            ['echo', 'foo\nbar'], stdout=subprocess.PIPE, stderr=self.dev_null
        )  # grep shows usage and calls exit(2) when called w/o arguments.
        self.assertRaises(ScriptError,
                          run_command,
                          command_returns_non_zero,
                          input=input_process.stdout)
Example #3
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 #4
0
 def ensure_clean_working_directory(self, force_clean):
     if not force_clean and not self.working_directory_is_clean():
         print run_command(self.status_command(), error_handler=Executive.ignore_error)
         raise ScriptError(message="Working directory has modifications, pass --force-clean or --no-clean to continue.")
     
     log("Cleaning working directory")
     self.clean_working_directory()
Example #5
0
    def test_run_command_with_bad_command_check_calls_error_handler(self):
        self.didHandleErrorGetCalled = False
        def handleError(scriptError):
            self.didHandleErrorGetCalled = True
            self.assertEqual(scriptError.exit_code, 2)

        run_command(["foo_bar_command_blah"], error_handler=handleError)
        self.assertTrue(self.didHandleErrorGetCalled)
    def test_run_command_with_bad_command_check_calls_error_handler(self):
        self.didHandleErrorGetCalled = False

        def handleError(scriptError):
            self.didHandleErrorGetCalled = True
            self.assertEqual(scriptError.exit_code, 2)

        run_command(["foo_bar_command_blah"], error_handler=handleError)
        self.assertTrue(self.didHandleErrorGetCalled)
Example #7
0
    def apply_patch(self, patch, force=False):
        # It's possible that the patch was not made from the root directory.
        # We should detect and handle that case.
        curl_process = subprocess.Popen(['curl', '--location', '--silent', '--show-error', patch['url']], stdout=subprocess.PIPE)
        args = [self.script_path('svn-apply')]
        if patch.get('reviewer'):
            args += ['--reviewer', patch['reviewer']]
        if force:
            args.append('--force')

        run_command(args, input=curl_process.stdout)
Example #8
0
    def setup(cls, test_object):
        # Create an test SVN repository
        test_object.svn_repo_path = tempfile.mkdtemp(suffix="svn_test_repo")
        test_object.svn_repo_url = "file://%s" % test_object.svn_repo_path # Not sure this will work on windows
        # git svn complains if we don't pass --pre-1.5-compatible, not sure why:
        # Expected FS format '2'; found format '3' at /usr/local/libexec/git-core//git-svn line 1477
        run_command(['svnadmin', 'create', '--pre-1.5-compatible', test_object.svn_repo_path])

        # Create a test svn checkout
        test_object.svn_checkout_path = tempfile.mkdtemp(suffix="svn_test_checkout")
        run_command(['svn', 'checkout', '--quiet', test_object.svn_repo_url, test_object.svn_checkout_path])

        cls._setup_test_commits(test_object)
Example #9
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)
        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.scm.apply_patch(self._create_patch(patch))
        self.assertEqual(file_contents, read_from_path(test_file_path))

        # Check if we can create a patch from a local commit.
        write_into_file_at_path(test_file_path, file_contents)
        run_command(['git', 'add', test_file_name])
        run_command(['git', 'commit', '-m', 'binary diff'])
        patch_from_local_commit = scm.create_patch_from_local_commit('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))
        patch_since_local_commit = scm.create_patch_since_local_commit('HEAD^1')
        self.assertTrue(re.search(r'\nliteral 0\n', patch_since_local_commit))
        self.assertTrue(re.search(r'\nliteral 256\n', patch_since_local_commit))
        self.assertEqual(patch_from_local_commit, patch_since_local_commit)
Example #10
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)
        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.scm.apply_patch(self._create_patch(patch))
        self.assertEqual(file_contents, read_from_path(test_file_path))

        # Check if we can create a patch from a local commit.
        write_into_file_at_path(test_file_path, file_contents)
        run_command(['git', 'add', test_file_name])
        run_command(['git', 'commit', '-m', 'binary diff'])
        patch_from_local_commit = scm.create_patch_from_local_commit('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))
        patch_since_local_commit = scm.create_patch_since_local_commit(
            'HEAD^1')
        self.assertTrue(re.search(r'\nliteral 0\n', patch_since_local_commit))
        self.assertTrue(re.search(r'\nliteral 256\n',
                                  patch_since_local_commit))
        self.assertEqual(patch_from_local_commit, patch_since_local_commit)
Example #11
0
    def apply_reverse_diff(self, revision):
        # Assume the revision is an svn revision.
        git_commit = self.git_commit_from_svn_revision(revision)
        if not git_commit:
            raise ScriptError(message='Failed to find git commit for revision %s, git svn log output: "%s"' % (revision, git_commit))

        # I think this will always fail due to ChangeLogs.
        # FIXME: We need to detec specific failure conditions and handle them.
        run_command(['git', 'revert', '--no-commit', git_commit], error_handler=Executive.ignore_error)

        # Fix any ChangeLogs if necessary.
        changelog_paths = self.modified_changelogs()
        if len(changelog_paths):
            run_command([self.script_path('resolve-ChangeLogs')] + changelog_paths)
Example #12
0
    def commit_ids_from_commitish_arguments(self, args):
        if not len(args):
            # FIXME: trunk is not always the remote branch name, need a way to detect the name.
            args.append('trunk..HEAD')

        commit_ids = []
        for commitish in args:
            if '...' in commitish:
                raise ScriptError(message="'...' is not supported (found in '%s'). Did you mean '..'?" % commitish)
            elif '..' in commitish:
                commit_ids += reversed(run_command(['git', 'rev-list', commitish]).splitlines())
            else:
                # Turn single commits or branch or tag names into commit ids.
                commit_ids += run_command(['git', 'rev-parse', '--revs-only', commitish]).splitlines()
        return commit_ids
Example #13
0
    def test_run_command_with_pipe(self):
        input_process = subprocess.Popen(['echo', 'foo\nbar'], stdout=subprocess.PIPE, stderr=self.dev_null)
        self.assertEqual(run_command(['grep', 'bar'], input=input_process.stdout), "bar\n")

        # Test the non-pipe case too:
        self.assertEqual(run_command(['grep', 'bar'], input="foo\nbar"), "bar\n")

        command_returns_non_zero = ['/bin/sh', '--invalid-option']
        # Test when the input pipe process fails.
        input_process = subprocess.Popen(command_returns_non_zero, stdout=subprocess.PIPE, stderr=self.dev_null)
        self.assertTrue(input_process.poll() != 0)
        self.assertRaises(ScriptError, run_command, ['grep', 'bar'], input=input_process.stdout)

        # Test when the run_command process fails.
        input_process = subprocess.Popen(['echo', 'foo\nbar'], stdout=subprocess.PIPE, stderr=self.dev_null) # grep shows usage and calls exit(2) when called w/o arguments.
        self.assertRaises(ScriptError, run_command, command_returns_non_zero, input=input_process.stdout)
Example #14
0
 def find_checkout_root(cls, path):
     # "git rev-parse --show-cdup" would be another way to get to the root
     (checkout_root, dot_git) = os.path.split(run_command(['git', 'rev-parse', '--git-dir'], cwd=path))
     # If we were using 2.6 # checkout_root = os.path.relpath(checkout_root, path)
     if not os.path.isabs(checkout_root): # Sometimes git returns relative paths
         checkout_root = os.path.join(path, checkout_root)
     return checkout_root
Example #15
0
    def test_error_handlers(self):
        git_failure_message = "Merge conflict during commit: Your file or directory 'WebCore/ChangeLog' is probably out-of-date: resource out of date; try updating at /usr/local/libexec/git-core//git-svn line 469"
        svn_failure_message = """svn: Commit failed (details follow):
svn: File or directory 'ChangeLog' is out of date; try updating
svn: resource out of date; try updating
"""
        command_does_not_exist = ['does_not_exist', 'invalid_option']
        self.assertRaises(OSError, run_command, command_does_not_exist)
        self.assertRaises(OSError,
                          run_command,
                          command_does_not_exist,
                          error_handler=Executive.ignore_error)

        command_returns_non_zero = ['/bin/sh', '--invalid-option']
        self.assertRaises(ScriptError, run_command, command_returns_non_zero)
        # Check if returns error text:
        self.assertTrue(
            run_command(command_returns_non_zero,
                        error_handler=Executive.ignore_error))

        self.assertRaises(CheckoutNeedsUpdate, commit_error_handler,
                          ScriptError(output=git_failure_message))
        self.assertRaises(CheckoutNeedsUpdate, commit_error_handler,
                          ScriptError(output=svn_failure_message))
        self.assertRaises(ScriptError, commit_error_handler,
                          ScriptError(output='blah blah blah'))
Example #16
0
 def value_from_svn_info(cls, path, field_name):
     svn_info_args = ['svn', 'info', path]
     info_output = run_command(svn_info_args).rstrip()
     match = re.search("^%s: (?P<value>.+)$" % field_name, info_output, re.MULTILINE)
     if not match:
         raise ScriptError(script_args=svn_info_args, message='svn info did not contain a %s.' % field_name)
     return match.group('value')
Example #17
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 #18
0
    def commit_message_for_local_commit(self, commit_id):
        commit_lines = run_command(['git', 'cat-file', 'commit', commit_id]).splitlines()

        # Skip the git headers.
        first_line_after_headers = 0
        for line in commit_lines:
            first_line_after_headers += 1
            if line == "":
                break
        return CommitMessage(commit_lines[first_line_after_headers:])
Example #19
0
 def run_status_and_extract_filenames(self, status_command, status_regexp):
     filenames = []
     for line in run_command(status_command).splitlines():
         match = re.search(status_regexp, line)
         if not match:
             continue
         # status = match.group('status')
         filename = match.group('filename')
         filenames.append(filename)
     return filenames
Example #20
0
    def setup(cls, test_object):
        # Create an test SVN repository
        test_object.svn_repo_path = tempfile.mkdtemp(suffix="svn_test_repo")
        test_object.svn_repo_url = "file://%s" % test_object.svn_repo_path  # Not sure this will work on windows
        # git svn complains if we don't pass --pre-1.5-compatible, not sure why:
        # Expected FS format '2'; found format '3' at /usr/local/libexec/git-core//git-svn line 1477
        run_command([
            'svnadmin', 'create', '--pre-1.5-compatible',
            test_object.svn_repo_path
        ])

        # Create a test svn checkout
        test_object.svn_checkout_path = tempfile.mkdtemp(
            suffix="svn_test_checkout")
        run_command([
            'svn', 'checkout', '--quiet', test_object.svn_repo_url,
            test_object.svn_checkout_path
        ])

        cls._setup_test_commits(test_object)
Example #21
0
    def test_create_patch_is_full_patch(self):
        test_dir_path = os.path.join(self.svn_checkout_path, 'test_dir')
        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_dir'])

        # 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 #22
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 #23
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 #24
0
    def test_error_handlers(self):
        git_failure_message="Merge conflict during commit: Your file or directory 'WebCore/ChangeLog' is probably out-of-date: resource out of date; try updating at /usr/local/libexec/git-core//git-svn line 469"
        svn_failure_message="""svn: Commit failed (details follow):
svn: File or directory 'ChangeLog' is out of date; try updating
svn: resource out of date; try updating
"""
        command_does_not_exist = ['does_not_exist', 'invalid_option']
        self.assertRaises(OSError, run_command, command_does_not_exist)
        self.assertRaises(OSError, run_command, command_does_not_exist, error_handler=Executive.ignore_error)

        command_returns_non_zero = ['/bin/sh', '--invalid-option']
        self.assertRaises(ScriptError, run_command, command_returns_non_zero)
        # Check if returns error text:
        self.assertTrue(run_command(command_returns_non_zero, error_handler=Executive.ignore_error))

        self.assertRaises(CheckoutNeedsUpdate, commit_error_handler, ScriptError(output=git_failure_message))
        self.assertRaises(CheckoutNeedsUpdate, commit_error_handler, ScriptError(output=svn_failure_message))
        self.assertRaises(ScriptError, commit_error_handler, ScriptError(output='blah blah blah'))
Example #25
0
 def _tear_down_git_clone_of_svn_repository(self):
     run_command(['rm', '-rf', self.git_checkout_path])
Example #26
0
 def test_apply_svn_patch(self):
     scm = detect_scm_system(self.svn_checkout_path)
     patch = self._create_patch(run_command(['svn', 'diff', '-r4:3']))
     self._setup_webkittools_scripts_symlink(scm)
     scm.apply_patch(patch)
Example #27
0
 def commit_locally_with_message(self, message):
     run_command(['git', 'commit', '--all', '-F', '-'], input=message)
Example #28
0
 def test_apply_svn_patch(self):
     scm = detect_scm_system(self.svn_checkout_path)
     patch = self._create_patch(run_command(['svn', 'diff', '-r4:3']))
     self._setup_webkittools_scripts_symlink(scm)
     scm.apply_patch(patch)
Example #29
0
 def test_run_command_with_bad_command_check_return_code(self):
     self.assertEqual(run_command(["foo_bar_command_blah"], error_handler=Executive.ignore_error, return_exit_code=True), 2)
Example #30
0
 def create_patch_from_local_commit(self, commit_id):
     return run_command(['git', 'diff', '--binary', commit_id + "^.." + commit_id])
Example #31
0
 def test_apply_git_patch(self):
     scm = detect_scm_system(self.git_checkout_path)
     patch = self._create_patch(run_command(['git', 'diff', 'HEAD..HEAD^']))
     self._setup_webkittools_scripts_symlink(scm)
     scm.apply_patch(patch)
 def test_run_command_with_bad_command_check_return_code(self):
     self.assertEqual(
         run_command(["foo_bar_command_blah"],
                     error_handler=Executive.ignore_error,
                     return_exit_code=True), 2)
Example #33
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])
Example #34
0
    def _setup_test_commits(test_object):
        # Add some test commits
        os.chdir(test_object.svn_checkout_path)
        test_file = open('test_file', 'w')
        test_file.write("test1")
        test_file.flush()
        
        run_command(['svn', 'add', 'test_file'])
        run_command(['svn', 'commit', '--quiet', '--message', 'initial commit'])
        
        test_file.write("test2")
        test_file.flush()
        
        run_command(['svn', 'commit', '--quiet', '--message', 'second commit'])
        
        test_file.write("test3\n")
        test_file.flush()
        
        run_command(['svn', 'commit', '--quiet', '--message', 'third commit'])

        test_file.write("test4\n")
        test_file.close()

        run_command(['svn', 'commit', '--quiet', '--message', 'fourth commit'])

        # svn does not seem to update after commit as I would expect.
        run_command(['svn', 'update'])
Example #35
0
 def test_apply_git_patch_force(self):
     scm = detect_scm_system(self.git_checkout_path)
     patch = self._create_patch(run_command(['git', 'diff', 'HEAD~2..HEAD']))
     self._setup_webkittools_scripts_symlink(scm)
     self.assertRaises(ScriptError, scm.apply_patch, patch, force=True)
Example #36
0
 def last_svn_commit_log(self):
     return run_command(['git', 'svn', 'log', '--limit=1'])
Example #37
0
    def test_svn_apply(self):
        first_entry = """2009-10-26  Eric Seidel  <*****@*****.**>

        Reviewed by Foo Bar.

        Most awesome change ever.

        * scm_unittest.py:
"""
        intermediate_entry = """2009-10-27  Eric Seidel  <*****@*****.**>

        Reviewed by Baz Bar.

        A more awesomer change yet!

        * scm_unittest.py:
"""
        one_line_overlap_patch = """Index: WebKitTools/ChangeLog
===================================================================
--- WebKitTools/ChangeLog	(revision 5)
+++ WebKitTools/ChangeLog	(working copy)
@@ -1,5 +1,13 @@
 2009-10-26  Eric Seidel  <*****@*****.**>

+        Reviewed by NOBODY (OOPS!).
+
+        Second most awsome change ever.
+
+        * scm_unittest.py:
+
+2009-10-26  Eric Seidel  <*****@*****.**>
+
         Reviewed by Foo Bar.

         Most awesome change ever.
"""
        one_line_overlap_entry = """DATE_HERE  Eric Seidel  <*****@*****.**>

        Reviewed by REVIEWER_HERE.

        Second most awsome change ever.

        * scm_unittest.py:
"""
        two_line_overlap_patch = """Index: WebKitTools/ChangeLog
===================================================================
--- WebKitTools/ChangeLog	(revision 5)
+++ WebKitTools/ChangeLog	(working copy)
@@ -2,6 +2,14 @@

         Reviewed by Foo Bar.

+        Second most awsome change ever.
+
+        * scm_unittest.py:
+
+2009-10-26  Eric Seidel  <*****@*****.**>
+
+        Reviewed by Foo Bar.
+
         Most awesome change ever.

         * scm_unittest.py:
"""
        two_line_overlap_entry = """DATE_HERE  Eric Seidel  <*****@*****.**>

        Reviewed by Foo Bar.

        Second most awsome change ever.

        * scm_unittest.py:
"""
        write_into_file_at_path('ChangeLog', first_entry)
        run_command(['svn', 'add', 'ChangeLog'])
        run_command(['svn', 'commit', '--quiet', '--message', 'ChangeLog commit'])

        # Patch files were created against just 'first_entry'.
        # Add a second commit to make svn-apply have to apply the patches with fuzz.
        changelog_contents = "%s\n%s" % (intermediate_entry, first_entry)
        write_into_file_at_path('ChangeLog', changelog_contents)
        run_command(['svn', 'commit', '--quiet', '--message', 'Intermediate commit'])

        self._setup_webkittools_scripts_symlink(self.scm)
        self.scm.apply_patch(self._create_patch(one_line_overlap_patch))
        expected_changelog_contents = "%s\n%s" % (self._set_date_and_reviewer(one_line_overlap_entry), changelog_contents)
        self.assertEquals(read_from_path('ChangeLog'), expected_changelog_contents)

        self.scm.revert_files(['ChangeLog'])
        self.scm.apply_patch(self._create_patch(two_line_overlap_patch))
        expected_changelog_contents = "%s\n%s" % (self._set_date_and_reviewer(two_line_overlap_entry), changelog_contents)
        self.assertEquals(read_from_path('ChangeLog'), expected_changelog_contents)
Example #38
0
 def create_patch_since_local_commit(self, commit_id):
     return run_command(['git', 'diff', '--binary', commit_id])
Example #39
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])
Example #40
0
 def files_changed_summary_for_commit(self, commit_id):
     return run_command(['git', 'diff-tree', '--shortstat', '--no-commit-id', commit_id])
Example #41
0
 def test_apply_git_patch_force(self):
     scm = detect_scm_system(self.git_checkout_path)
     patch = self._create_patch(run_command(['git', 'diff',
                                             'HEAD~2..HEAD']))
     self._setup_webkittools_scripts_symlink(scm)
     self.assertRaises(ScriptError, scm.apply_patch, patch, force=True)
Example #42
0
 def push_local_commits_to_server(self):
     if self.dryrun:
         # Return a string which looks like a commit so that things which parse this output will succeed.
         return "Dry run, no remote commit.\nCommitted r0"
     return run_command(['git', 'svn', 'dcommit'], error_handler=commit_error_handler)
Example #43
0
    def _setup_test_commits(test_object):
        # Add some test commits
        os.chdir(test_object.svn_checkout_path)
        test_file = open('test_file', 'w')
        test_file.write("test1")
        test_file.flush()

        run_command(['svn', 'add', 'test_file'])
        run_command(
            ['svn', 'commit', '--quiet', '--message', 'initial commit'])

        test_file.write("test2")
        test_file.flush()

        run_command(['svn', 'commit', '--quiet', '--message', 'second commit'])

        test_file.write("test3\n")
        test_file.flush()

        run_command(['svn', 'commit', '--quiet', '--message', 'third commit'])

        test_file.write("test4\n")
        test_file.close()

        run_command(['svn', 'commit', '--quiet', '--message', 'fourth commit'])

        # svn does not seem to update after commit as I would expect.
        run_command(['svn', 'update'])
Example #44
0
    def test_svn_apply(self):
        first_entry = """2009-10-26  Eric Seidel  <*****@*****.**>

        Reviewed by Foo Bar.

        Most awesome change ever.

        * scm_unittest.py:
"""
        intermediate_entry = """2009-10-27  Eric Seidel  <*****@*****.**>

        Reviewed by Baz Bar.

        A more awesomer change yet!

        * scm_unittest.py:
"""
        one_line_overlap_patch = """Index: WebKitTools/ChangeLog
===================================================================
--- WebKitTools/ChangeLog	(revision 5)
+++ WebKitTools/ChangeLog	(working copy)
@@ -1,5 +1,13 @@
 2009-10-26  Eric Seidel  <*****@*****.**>

+        Reviewed by NOBODY (OOPS!).
+
+        Second most awsome change ever.
+
+        * scm_unittest.py:
+
+2009-10-26  Eric Seidel  <*****@*****.**>
+
         Reviewed by Foo Bar.

         Most awesome change ever.
"""
        one_line_overlap_entry = """DATE_HERE  Eric Seidel  <*****@*****.**>

        Reviewed by REVIEWER_HERE.

        Second most awsome change ever.

        * scm_unittest.py:
"""
        two_line_overlap_patch = """Index: WebKitTools/ChangeLog
===================================================================
--- WebKitTools/ChangeLog	(revision 5)
+++ WebKitTools/ChangeLog	(working copy)
@@ -2,6 +2,14 @@

         Reviewed by Foo Bar.

+        Second most awsome change ever.
+
+        * scm_unittest.py:
+
+2009-10-26  Eric Seidel  <*****@*****.**>
+
+        Reviewed by Foo Bar.
+
         Most awesome change ever.

         * scm_unittest.py:
"""
        two_line_overlap_entry = """DATE_HERE  Eric Seidel  <*****@*****.**>

        Reviewed by Foo Bar.

        Second most awsome change ever.

        * scm_unittest.py:
"""
        write_into_file_at_path('ChangeLog', first_entry)
        run_command(['svn', 'add', 'ChangeLog'])
        run_command(
            ['svn', 'commit', '--quiet', '--message', 'ChangeLog commit'])

        # Patch files were created against just 'first_entry'.
        # Add a second commit to make svn-apply have to apply the patches with fuzz.
        changelog_contents = "%s\n%s" % (intermediate_entry, first_entry)
        write_into_file_at_path('ChangeLog', changelog_contents)
        run_command(
            ['svn', 'commit', '--quiet', '--message', 'Intermediate commit'])

        self._setup_webkittools_scripts_symlink(self.scm)
        self.scm.apply_patch(self._create_patch(one_line_overlap_patch))
        expected_changelog_contents = "%s\n%s" % (self._set_date_and_reviewer(
            one_line_overlap_entry), changelog_contents)
        self.assertEquals(read_from_path('ChangeLog'),
                          expected_changelog_contents)

        self.scm.revert_files(['ChangeLog'])
        self.scm.apply_patch(self._create_patch(two_line_overlap_patch))
        expected_changelog_contents = "%s\n%s" % (self._set_date_and_reviewer(
            two_line_overlap_entry), changelog_contents)
        self.assertEquals(read_from_path('ChangeLog'),
                          expected_changelog_contents)
Example #45
0
 def test_apply_git_patch(self):
     scm = detect_scm_system(self.git_checkout_path)
     patch = self._create_patch(run_command(['git', 'diff', 'HEAD..HEAD^']))
     self._setup_webkittools_scripts_symlink(scm)
     scm.apply_patch(patch)
Example #46
0
 def _tear_down_git_clone_of_svn_repository(self):
     run_command(['rm', '-rf', self.git_checkout_path])