Ejemplo n.º 1
0
 def begin_work_queue(self):
     log("CAUTION: %s will discard all local changes in \"%s\"" % (self.name, self.tool.scm().checkout_root))
     if self.options.confirm:
         response = self.tool.user.prompt("Are you sure?  Type \"yes\" to continue: ")
         if (response != "yes"):
             error("User declined.")
     log("Running WebKit %s." % self.name)
Ejemplo n.º 2
0
    def execute(self, options, args, tool):
        bug_id = options.bug_id

        svn_revision = args and args[0]
        if svn_revision:
            if re.match("^r[0-9]+$", svn_revision, re.IGNORECASE):
                svn_revision = svn_revision[1:]
            if not re.match("^[0-9]+$", svn_revision):
                error("Invalid svn revision: '%s'" % svn_revision)

        needs_prompt = False
        if not bug_id or not svn_revision:
            needs_prompt = True
            (bug_id, svn_revision) = self._determine_bug_id_and_svn_revision(tool, bug_id, svn_revision)

        log("Bug: <%s> %s" % (tool.bugs.bug_url_for_bug_id(bug_id), tool.bugs.fetch_bug_dictionary(bug_id)["title"]))
        log("Revision: %s" % svn_revision)

        if options.open_bug:
            tool.user.open_url(tool.bugs.bug_url_for_bug_id(bug_id))

        if needs_prompt:
            if not tool.user.confirm("Is this correct?"):
                self._exit(1)

        bug_comment = bug_comment_from_svn_revision(svn_revision)
        if options.comment:
            bug_comment = "%s\n\n%s" % (options.comment, bug_comment)

        if options.update_only:
            log("Adding comment to Bug %s." % bug_id)
            tool.bugs.post_comment_to_bug(bug_id, bug_comment)
        else:
            log("Adding comment to Bug %s and marking as Resolved/Fixed." % bug_id)
            tool.bugs.close_bug_as_fixed(bug_id, bug_comment)
Ejemplo n.º 3
0
    def create_bug_from_commit(self, options, args, tool):
        commit_ids = tool.scm().commit_ids_from_commitish_arguments(args)
        if len(commit_ids) > 3:
            error("Are you sure you want to create one bug with %s patches?" % len(commit_ids))

        commit_id = commit_ids[0]

        bug_title = ""
        comment_text = ""
        if options.prompt:
            (bug_title, comment_text) = self.prompt_for_bug_title_and_comment()
        else:
            commit_message = tool.scm().commit_message_for_local_commit(commit_id)
            bug_title = commit_message.description(lstrip=True, strip_url=True)
            comment_text = commit_message.body(lstrip=True)
            comment_text += "---\n"
            comment_text += tool.scm().files_changed_summary_for_commit(commit_id)

        diff = tool.scm().create_patch(git_commit=commit_id)
        bug_id = tool.bugs.create_bug(bug_title, comment_text, options.component, diff, "Patch", cc=options.cc, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)

        if bug_id and len(commit_ids) > 1:
            options.bug_id = bug_id
            options.obsolete_patches = False
            # FIXME: We should pass through --no-comment switch as well.
            PostCommits.execute(self, options, commit_ids[1:], tool)
Ejemplo n.º 4
0
 def execute(self, options, args, tool):
     if len(args):
         if (not tool.scm().supports_local_commits()):
             error("Extra arguments not supported; patch is taken from working directory.")
         self.create_bug_from_commit(options, args, tool)
     else:
         self.create_bug_from_patch(options, args, tool)
Ejemplo n.º 5
0
 def begin_work_queue(self):
     log('CAUTION: %s will discard all local changes in "%s"' % (self.name, self._tool.scm().checkout_root))
     if self.options.confirm:
         response = self._tool.user.prompt('Are you sure?  Type "yes" to continue: ')
         if response != "yes":
             error("User declined.")
     log("Running WebKit %s." % self.name)
     self._tool.status_server.update_status(self.name, "Starting Queue")
Ejemplo n.º 6
0
 def run(self, state):
     if not self._options.check_builders:
         return
     red_builders_names = self._tool.buildbot.red_core_builders_names()
     if not red_builders_names:
         return
     red_builders_names = map(lambda name: "\"%s\"" % name, red_builders_names) # Add quotes around the names.
     error("Builders [%s] are red, please do not commit.\nSee http://%s.\nPass --ignore-builders to bypass this check." % (", ".join(red_builders_names), self._tool.buildbot.buildbot_host))
Ejemplo n.º 7
0
 def ensure_no_local_commits(self, force):
     if not self.supports_local_commits():
         return
     commits = self.local_commits()
     if not len(commits):
         return
     if not force:
         error("Working directory has local commits, pass --force-clean to continue.")
     self.discard_local_commits()
Ejemplo n.º 8
0
 def _validate_revisions(self, current_chromium_revision, new_chromium_revision):
     if new_chromium_revision < current_chromium_revision:
         log("Current Chromium DEPS revision %s is newer than %s." % (current_chromium_revision, new_chromium_revision))
         new_chromium_revision = self._tool.user.prompt("Enter new chromium revision (enter nothing to cancel):\n")
         try:
             new_chromium_revision = int(new_chromium_revision)
         except ValueError, TypeError:
             new_chromium_revision = None
         if not new_chromium_revision:
             error("Unable to update Chromium DEPS")
Ejemplo n.º 9
0
 def _validate_revisions(self, current_chromium_revision, new_chromium_revision):
     if new_chromium_revision < current_chromium_revision:
         message = "Current Chromium DEPS revision %s is newer than %s." % (current_chromium_revision, new_chromium_revision)
         if self._options.non_interactive:
             error(message)  # Causes the process to terminate.
         log(message)
         new_chromium_revision = self._tool.user.prompt("Enter new chromium revision (enter nothing to cancel):\n")
         try:
             new_chromium_revision = int(new_chromium_revision)
         except ValueError, TypeError:
             new_chromium_revision = None
         if not new_chromium_revision:
             error("Unable to update Chromium DEPS")
Ejemplo n.º 10
0
 def run(self, state):
     if self.cached_lookup(state, "changelogs"):
         return
     os.chdir(self._tool.scm().checkout_root)
     args = [self.port().script_path("prepare-ChangeLog")]
     if state["bug_id"]:
         args.append("--bug=%s" % state["bug_id"])
     if self._options.email:
         args.append("--email=%s" % self._options.email)
     try:
         self._tool.executive.run_and_throw_if_fail(args, self._options.quiet)
     except ScriptError, e:
         error("Unable to prepare ChangeLogs.")
Ejemplo n.º 11
0
 def run(self, state):
     # FIXME: For now we disable this check when a user is driving the script
     # this check is too draconian (and too poorly tested) to foist upon users.
     if not self._options.non_interactive:
         return
     for changelog_path in self.cached_lookup(state, "changelogs"):
         changelog_entry = ChangeLog(changelog_path).latest_entry()
         if self._has_valid_reviewer(changelog_entry):
             continue
         reviewer_text = changelog_entry.reviewer_text()
         if reviewer_text:
             log("%s found in %s does not appear to be a valid reviewer according to committers.py." % (reviewer_text, changelog_path))
         error('%s neither lists a valid reviewer nor contains the string "Unreviewed" or "Rubber stamp" (case insensitive).' % changelog_path)
Ejemplo n.º 12
0
 def run(self, state):
     changed_files = self.cached_lookup(state, "changed_files")
     for filename in changed_files:
         if not self._tool.checkout().is_path_to_changelog(filename):
             continue
         # Diff ChangeLogs directly because svn-create-patch will move
         # ChangeLog entries to the # top automatically, defeating our
         # validation here.
         # FIXME: Should we diff all the ChangeLogs at once?
         diff = self._tool.scm().diff_for_file(filename)
         parsed_diff = DiffParser(diff.splitlines())
         for filename, diff_file in parsed_diff.files.items():
             if not self._check_changelog_diff(diff_file):
                 error("ChangeLog entry in %s is not at the top of the file." % diff_file.filename)
Ejemplo n.º 13
0
 def run(self, state):
     # FIXME: For now we disable this check when a user is driving the script
     # this check is too draconian (and too poorly tested) to foist upon users.
     if not self._options.non_interactive:
         return
     # FIXME: We should figure out how to handle the current working
     #        directory issue more globally.
     os.chdir(self._tool.scm().checkout_root)
     for changelog_path in self._tool.checkout().modified_changelogs(self._options.git_commit, self._options.squash):
         changelog_entry = ChangeLog(changelog_path).latest_entry()
         if self._has_valid_reviewer(changelog_entry):
             continue
         reviewer_text = changelog_entry.reviewer_text()
         if reviewer_text:
             log("%s found in %s does not appear to be a valid reviewer according to committers.py." % (reviewer_text, changelog_path))
         error('%s neither lists a valid reviewer nor contains the string "Unreviewed" or "Rubber stamp" (case insensitive).' % changelog_path)
Ejemplo n.º 14
0
    def run(self, state):
        if self.cached_lookup(state, "changelogs"):
            self._ensure_bug_url(state)
            return
        os.chdir(self._tool.scm().checkout_root)
        args = [self._tool.port().script_path("prepare-ChangeLog")]
        if state.get("bug_id"):
            args.append("--bug=%s" % state["bug_id"])
        if self._options.email:
            args.append("--email=%s" % self._options.email)

        if self._tool.scm().supports_local_commits():
            args.append("--merge-base=%s" % self._tool.scm().merge_base(self._options.git_commit))

        try:
            self._tool.executive.run_and_throw_if_fail(args, self._options.quiet)
        except ScriptError, e:
            error("Unable to prepare ChangeLogs.")
Ejemplo n.º 15
0
def default_scm(patch_directories=None):
    """Return the default SCM object as determined by the CWD and running code.

    Returns the default SCM object for the current working directory; if the
    CWD is not in a checkout, then we attempt to figure out if the SCM module
    itself is part of a checkout, and return that one. If neither is part of
    a checkout, None is returned.

    """
    cwd = os.getcwd()
    scm_system = detect_scm_system(cwd, patch_directories)
    if not scm_system:
        script_directory = os.path.dirname(os.path.abspath(__file__))
        scm_system = detect_scm_system(script_directory, patch_directories)
        if scm_system:
            log("The current directory (%s) is not a WebKit checkout, using %s" % (cwd, scm_system.checkout_root))
        else:
            error("FATAL: Failed to determine the SCM system for either %s or %s" % (cwd, script_directory))
    return scm_system
Ejemplo n.º 16
0
    def run(self, state):
        if self.cached_lookup(state, "changelogs"):
            self._ensure_bug_url(state)
            return
        args = self._tool.port().prepare_changelog_command()
        if state.get("bug_id"):
            args.append("--bug=%s" % state["bug_id"])
            args.append("--description=%s" % self.cached_lookup(state, 'bug_title'))
        if self._options.email:
            args.append("--email=%s" % self._options.email)

        if self._tool.scm().supports_local_commits():
            args.append("--merge-base=%s" % self._tool.scm().merge_base(self._options.git_commit))

        args.extend(self._changed_files(state))

        try:
            self._tool.executive.run_and_throw_if_fail(args, self._options.quiet, cwd=self._tool.scm().checkout_root)
        except ScriptError, e:
            error("Unable to prepare ChangeLogs.")
Ejemplo n.º 17
0
    def _determine_bug_id_and_svn_revision(self, tool, bug_id, svn_revision):
        commit_log = self._fetch_commit_log(tool, svn_revision)

        if not bug_id:
            bug_id = parse_bug_id_from_changelog(commit_log)

        if not svn_revision:
            match = re.search("^r(?P<svn_revision>\d+) \|", commit_log, re.MULTILINE)
            if match:
                svn_revision = match.group('svn_revision')

        if not bug_id or not svn_revision:
            not_found = []
            if not bug_id:
                not_found.append("bug id")
            if not svn_revision:
                not_found.append("svn revision")
            error("Could not find %s on command-line or in %s."
                  % (" or ".join(not_found), "r%s" % svn_revision if svn_revision else "last commit"))

        return (bug_id, svn_revision)
Ejemplo n.º 18
0
    def execute(self, options, args, tool):
        commit_ids = tool.scm().commit_ids_from_commitish_arguments(args)
        if len(commit_ids) > 10:  # We could lower this limit, 10 is too many for one bug as-is.
            error(
                "webkit-patch does not support attaching %s at once.  Are you sure you passed the right commit range?"
                % (pluralize("patch", len(commit_ids)))
            )

        have_obsoleted_patches = set()
        for commit_id in commit_ids:
            commit_message = tool.scm().commit_message_for_local_commit(commit_id)

            # Prefer --bug-id=, then a bug url in the commit message, then a bug url in the entire commit diff (i.e. ChangeLogs).
            bug_id = (
                options.bug_id
                or parse_bug_id(commit_message.message())
                or parse_bug_id(tool.scm().create_patch(git_commit=commit_id))
            )
            if not bug_id:
                log("Skipping %s: No bug id found in commit or specified with --bug-id." % commit_id)
                continue

            if options.obsolete_patches and bug_id not in have_obsoleted_patches:
                state = {"bug_id": bug_id}
                steps.ObsoletePatches(tool, options).run(state)
                have_obsoleted_patches.add(bug_id)

            diff = tool.scm().create_patch(git_commit=commit_id)
            description = options.description or commit_message.description(lstrip=True, strip_url=True)
            comment_text = self._comment_text_for_commit(options, commit_message, tool, commit_id)
            tool.bugs.add_patch_to_bug(
                bug_id,
                diff,
                description,
                comment_text,
                mark_for_review=options.review,
                mark_for_commit_queue=options.request_commit,
            )
Ejemplo n.º 19
0
    def _determine_bug_id_and_svn_revision(self, tool, bug_id, svn_revision):
        commit_log = self._fetch_commit_log(tool, svn_revision)

        if not bug_id:
            bug_id = parse_bug_id_from_changelog(commit_log)

        if not svn_revision:
            match = re.search("^r(?P<svn_revision>\d+) \|", commit_log,
                              re.MULTILINE)
            if match:
                svn_revision = match.group('svn_revision')

        if not bug_id or not svn_revision:
            not_found = []
            if not bug_id:
                not_found.append("bug id")
            if not svn_revision:
                not_found.append("svn revision")
            error("Could not find %s on command-line or in %s." %
                  (" or ".join(not_found),
                   "r%s" % svn_revision if svn_revision else "last commit"))

        return (bug_id, svn_revision)
Ejemplo n.º 20
0
    def run(self, state):
        if self.cached_lookup(state, "changelogs"):
            self._ensure_bug_url(state)
            return
        args = self._tool.port().prepare_changelog_command()
        if state.get("bug_id"):
            args.append("--bug=%s" % state["bug_id"])
            args.append("--description=%s" %
                        self.cached_lookup(state, 'bug_title'))
        if self._options.email:
            args.append("--email=%s" % self._options.email)

        if self._tool.scm().supports_local_commits():
            args.append("--merge-base=%s" %
                        self._tool.scm().merge_base(self._options.git_commit))

        args.extend(self._changed_files(state))

        try:
            self._tool.executive.run_and_throw_if_fail(
                args, self._options.quiet, cwd=self._tool.scm().checkout_root)
        except ScriptError, e:
            error("Unable to prepare ChangeLogs.")
Ejemplo n.º 21
0
    def create_bug_from_commit(self, options, args, tool):
        commit_ids = tool.scm().commit_ids_from_commitish_arguments(args)
        if len(commit_ids) > 3:
            error("Are you sure you want to create one bug with %s patches?" %
                  len(commit_ids))

        commit_id = commit_ids[0]

        bug_title = ""
        comment_text = ""
        if options.prompt:
            (bug_title, comment_text) = self.prompt_for_bug_title_and_comment()
        else:
            commit_message = tool.scm().commit_message_for_local_commit(
                commit_id)
            bug_title = commit_message.description(lstrip=True, strip_url=True)
            comment_text = commit_message.body(lstrip=True)
            comment_text += "---\n"
            comment_text += tool.scm().files_changed_summary_for_commit(
                commit_id)

        diff = tool.scm().create_patch(git_commit=commit_id)
        bug_id = tool.bugs.create_bug(
            bug_title,
            comment_text,
            options.component,
            diff,
            "Patch",
            cc=options.cc,
            mark_for_review=options.review,
            mark_for_commit_queue=options.request_commit)

        if bug_id and len(commit_ids) > 1:
            options.bug_id = bug_id
            options.obsolete_patches = False
            # FIXME: We should pass through --no-comment switch as well.
            PostCommits.execute(self, options, commit_ids[1:], tool)
Ejemplo n.º 22
0
    def execute(self, options, args, tool):
        commit_ids = tool.scm().commit_ids_from_commitish_arguments(args)
        if len(commit_ids) > 10: # We could lower this limit, 10 is too many for one bug as-is.
            error("webkit-patch does not support attaching %s at once.  Are you sure you passed the right commit range?" % (pluralize("patch", len(commit_ids))))

        have_obsoleted_patches = set()
        for commit_id in commit_ids:
            commit_message = tool.scm().commit_message_for_local_commit(commit_id)

            # Prefer --bug-id=, then a bug url in the commit message, then a bug url in the entire commit diff (i.e. ChangeLogs).
            bug_id = options.bug_id or parse_bug_id(commit_message.message()) or parse_bug_id(tool.scm().create_patch(git_commit=commit_id))
            if not bug_id:
                log("Skipping %s: No bug id found in commit or specified with --bug-id." % commit_id)
                continue

            if options.obsolete_patches and bug_id not in have_obsoleted_patches:
                state = { "bug_id": bug_id }
                steps.ObsoletePatches(tool, options).run(state)
                have_obsoleted_patches.add(bug_id)

            diff = tool.scm().create_patch(git_commit=commit_id)
            description = options.description or commit_message.description(lstrip=True, strip_url=True)
            comment_text = self._comment_text_for_commit(options, commit_message, tool, commit_id)
            tool.bugs.add_patch_to_bug(bug_id, diff, description, comment_text, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)
Ejemplo n.º 23
0
 def commit_locally_with_message(self, message):
     error("Your source control manager does not support local commits.")
Ejemplo n.º 24
0
 def create_patch_since_local_commit(self, commit_id):
     error("Your source control manager does not support creating a patch from a local commit.")
Ejemplo n.º 25
0
 def run(self, state):
     parsed_diff = DiffParser(self.cached_lookup(state, "diff").splitlines())
     for filename, diff_file in parsed_diff.files.items():
         if not self._check_changelog_diff(diff_file):
             error("ChangeLog entry in %s is not at the top of the file." % diff_file.filename)
Ejemplo n.º 26
0
 def _prepare_state(self, options, args, tool):
     state = {}
     state["bug_id"] = self._bug_id(options, args, tool, state)
     if not state["bug_id"]:
         error("No bug id passed and no bug url found in ChangeLogs.")
     return state
Ejemplo n.º 27
0
 def _prepare_state(self, options, args, tool):
     state = {}
     state["bug_id"] = self._bug_id(options, args, tool, state)
     if not state["bug_id"]:
         error("No bug id passed and no bug url found in ChangeLogs.")
     return state
Ejemplo n.º 28
0
 def commit_locally_with_message(self, message):
     error("Your source control manager does not support local commits.")
 def run(self, state):
     if self._options.local_commit and not self._tool.scm().supports_local_commits():
         error("--local-commit passed, but %s does not support local commits" % self._tool.scm.display_name())
Ejemplo n.º 30
0
 def run(self, state):
     if self._options.local_commit and not self._tool.scm(
     ).supports_local_commits():
         error(
             "--local-commit passed, but %s does not support local commits"
             % self._tool.scm.display_name())