Example #1
0
 def _bug_id(self, args, tool, state):
     # Perfer a bug id passed as an argument over a bug url in the diff (i.e. ChangeLogs).
     bug_id = args and args[0]
     if not bug_id:
         state["diff"] = tool.scm().create_patch()
         bug_id = parse_bug_id(state["diff"])
     return bug_id
Example #2
0
 def _bug_id(self, args, tool, state):
     # Perfer a bug id passed as an argument over a bug url in the diff (i.e. ChangeLogs).
     bug_id = args and args[0]
     if not bug_id:
         state["diff"] = tool.scm().create_patch()
         bug_id = parse_bug_id(state["diff"])
     return bug_id
Example #3
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 #4
0
    def test_parse_bug_id(self):
        # FIXME: These would be all better as doctests
        bugs = Bugzilla()
        self.assertEquals(12345, parse_bug_id("http://webkit.org/b/12345"))
        self.assertEquals(12345, parse_bug_id("http://bugs.webkit.org/show_bug.cgi?id=12345"))
        self.assertEquals(12345, parse_bug_id(bugs.short_bug_url_for_bug_id(12345)))
        self.assertEquals(12345, parse_bug_id(bugs.bug_url_for_bug_id(12345)))
        self.assertEquals(12345, parse_bug_id(bugs.bug_url_for_bug_id(12345, xml=True)))

        # Our bug parser is super-fragile, but at least we're testing it.
        self.assertEquals(None, parse_bug_id("http://www.webkit.org/b/12345"))
        self.assertEquals(None, parse_bug_id("http://bugs.webkit.org/show_bug.cgi?ctype=xml&id=12345"))
Example #5
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 #6
0
 def commit_info_for_revision(cls, scm, revision):
     committer_email = scm.committer_email_for_revision(revision)
     changelog_entries = cls._changelog_entries_for_revision(scm, revision)
     # Assume for now that the first entry has everything we need:
     changelog_entry = changelog_entries[0]
     changelog_data = {
         "bug_id" : parse_bug_id(changelog_entry.contents()),
         "author_name" : changelog_entry.author_name(),
         "author_email" : changelog_entry.author_email(),
         "reviewer_text" : changelog_entry.reviewer_text(),
     }
     # We could pass the changelog_entry instead of a dictionary here, but that makes
     # mocking slightly more involved, and would make aggregating data from multiple
     # entries more difficult to wire in if we need to do that in the future.
     return cls(revision, committer_email, changelog_data)
Example #7
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 #8
0
    def test_parse_bug_id(self):
        # FIXME: These would be all better as doctests
        bugs = Bugzilla()
        self.assertEquals(12345, parse_bug_id("http://webkit.org/b/12345"))
        self.assertEquals(
            12345,
            parse_bug_id("http://bugs.webkit.org/show_bug.cgi?id=12345"))
        self.assertEquals(12345,
                          parse_bug_id(bugs.short_bug_url_for_bug_id(12345)))
        self.assertEquals(12345, parse_bug_id(bugs.bug_url_for_bug_id(12345)))
        self.assertEquals(
            12345, parse_bug_id(bugs.bug_url_for_bug_id(12345, xml=True)))

        # Our bug parser is super-fragile, but at least we're testing it.
        self.assertEquals(None, parse_bug_id("http://www.webkit.org/b/12345"))
        self.assertEquals(
            None,
            parse_bug_id(
                "http://bugs.webkit.org/show_bug.cgi?ctype=xml&id=12345"))
Example #9
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 #10
0
 def _prepare_state(self, options, args, tool):
     return {
         "bug_id" : (args and args[0]) or parse_bug_id(tool.scm().create_patch()),
     }
Example #11
0
 def _parse_bug_id_from_revision_diff(self, revision):
     original_diff = self.tool.scm().diff_for_revision(revision)
     return parse_bug_id(original_diff)
 def _prepare_state(self, options, args, tool):
     return {
         "bug_id" : (args and args[0]) or parse_bug_id(tool.scm().create_patch()),
     }
 def _parse_bug_id_from_revision_diff(tool, revision):
     original_diff = tool.scm().diff_for_revision(revision)
     return parse_bug_id(original_diff)