Пример #1
0
 def _prepare_state(self, options, args, tool):
     return {
         "patch" : {
             "id" : None,
             "bug_id" : (args and args[0]) or parse_bug_id(tool.scm().create_patch()),
         }
     }
Пример #2
0
 def _prepare_state(self, options, args, tool):
     return {
         "patch": {
             "id":
             None,
             "bug_id": (args and args[0])
             or parse_bug_id(tool.scm().create_patch()),
         }
     }
Пример #3
0
 def _prepare_state(self, options, args, tool):
     # Perfer a bug id passed as an argument over a bug url in the diff (i.e. ChangeLogs).
     state = {}
     bug_id = args and args[0]
     if not bug_id:
         state["diff"] = tool.scm().create_patch()
         bug_id = parse_bug_id(state["diff"])
     if not bug_id:
         error("No bug id passed and no bug url found in diff, can't post.")
     state["bug_id"] = bug_id
     return state
Пример #4
0
 def _prepare_state(self, options, args, tool):
     # Perfer a bug id passed as an argument over a bug url in the diff (i.e. ChangeLogs).
     state = {}
     bug_id = args and args[0]
     if not bug_id:
         state["diff"] = tool.scm().create_patch()
         bug_id = parse_bug_id(state["diff"])
     if not bug_id:
         error("No bug id passed and no bug url found in diff, can't post.")
     state["bug_id"] = bug_id
     return state
Пример #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(
                "bugzilla-tool 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}
                ObsoletePatchesOnBugStep(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)
Пример #6
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"))
Пример #7
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("bugzilla-tool 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 }
                ObsoletePatchesOnBugStep(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)
Пример #8
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)
Пример #9
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"))
Пример #10
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)
Пример #11
0
 def _parse_bug_id_from_revision_diff(tool, revision):
     original_diff = tool.scm().diff_for_revision(revision)
     return parse_bug_id(original_diff)
Пример #12
0
 def _parse_bug_id_from_revision_diff(tool, revision):
     original_diff = tool.scm().diff_for_revision(revision)
     return parse_bug_id(original_diff)