Ejemplo n.º 1
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'))
Ejemplo n.º 2
0
def run_silent(args, cwd=None):
    process = subprocess.Popen(args,
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE,
                               cwd=cwd)
    process.communicate()  # ignore output
    exit_code = process.wait()
    if exit_code:
        raise ScriptError('Failed to run "%s"  exit_code: %d  cwd: %s' %
                          (args, exit_code, cwd))
Ejemplo n.º 3
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')
Ejemplo n.º 4
0
    def commit_message_for_this_commit(self):
        changelog_paths = self.modified_changelogs()
        if not len(changelog_paths):
            raise ScriptError(
                message=
                "Found no modified ChangeLogs, cannot create a commit message.\n"
                "All changes require a ChangeLog.  See:\n"
                "http://webkit.org/coding/contributing.html")

        changelog_messages = []
        for changelog_path in changelog_paths:
            log("Parsing ChangeLog: %s" % changelog_path)
            changelog_entry = ChangeLog(changelog_path).latest_entry()
            if not changelog_entry:
                raise ScriptError(message="Failed to parse ChangeLog: " +
                                  os.path.abspath(changelog_path))
            changelog_messages.append(changelog_entry)

        # FIXME: We should sort and label the ChangeLog messages like commit-log-editor does.
        return CommitMessage("".join(changelog_messages).splitlines())
Ejemplo n.º 5
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()
Ejemplo n.º 6
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)
Ejemplo n.º 7
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
 def process_work_item(self, work_item):
     self.record("process_work_item")
     raise ScriptError(exit_code=self.error_code)
Ejemplo n.º 9
0
 def __init__(self, script_args, exit_code, output, cwd):
     ScriptError.__init__(self, script_args=script_args, exit_code=exit_code, output=output, cwd=cwd)
Ejemplo n.º 10
0
 def __init__(self, script_args, exit_code, output, cwd):
     ScriptError.__init__(self,
                          script_args=script_args,
                          exit_code=exit_code,
                          output=output,
                          cwd=cwd)
    def test_log(self):
        self.assert_log_equals("test", "test\n")

        # Test that log() does not throw an exception when passed an object instead of a string.
        self.assert_log_equals(ScriptError(message="ScriptError"),
                               "ScriptError\n")