Example #1
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_from_local_commit(commit_id)
        diff_file = StringIO.StringIO(diff) # create_bug expects a file-like object
        bug_id = tool.bugs.create_bug(bug_title, comment_text, options.component, diff_file, "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)
Example #2
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)
Example #3
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?"):
                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)
Example #4
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)
Example #5
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)
 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))
Example #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()
Example #8
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)
Example #9
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()
 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))
 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.")
Example #12
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(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)
Example #13
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_from_local_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_file = self._diff_file_for_commit(tool, 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_file,
                description,
                comment_text,
                mark_for_review=options.review,
                mark_for_commit_queue=options.request_commit)
Example #14
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_from_local_commit(commit_id)
        diff_file = StringIO.StringIO(
            diff)  # create_bug expects a file-like object
        bug_id = tool.bugs.create_bug(
            bug_title,
            comment_text,
            options.component,
            diff_file,
            "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)
Example #15
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?"):
                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)
Example #16
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_from_local_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_file = self._diff_file_for_commit(tool, 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_file,
                description,
                comment_text,
                mark_for_review=options.review,
                mark_for_commit_queue=options.request_commit,
            )
Example #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(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)
Example #18
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."
     )
Example #19
0
 def commit_locally_with_message(self, message):
     error("Your source control manager does not support local commits.")
Example #20
0
 def _prepare_state(self, options, args, tool):
     state = {}
     state["bug_id"] = self._bug_id(args, tool, state)
     if not state["bug_id"]:
         error("No bug id passed and no bug url found in diff.")
     return state
Example #21
0
 def _prepare_state(self, options, args, tool):
     state = {}
     state["bug_id"] = self._bug_id(args, tool, state)
     if not state["bug_id"]:
         error("No bug id passed and no bug url found in diff.")
     return state
 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())
Example #23
0
 def commit_locally_with_message(self, message):
     error("Your source control manager does not support local commits.")
Example #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.")
 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())