Example #1
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.short_bug_url_for_bug_id(bug_id), tool.bugs.fetch_bug_dictionary(bug_id)["title"]))
        log("Revision: %s" % svn_revision)

        if options.open_bug:
            self._open_bug_in_web_browser(tool, bug_id)

        if needs_prompt:
            self._prompt_user_for_correctness(bug_id, svn_revision)

        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 #2
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 #3
0
 def run(self, state):
     if not self._options.confirm:
         return
     diff = self.diff(state)
     self._tool.user.page(diff)
     if not self._tool.user.confirm():
         error("User declined to continue.")
Example #4
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 #5
0
    def authenticate(self):
        if self.authenticated:
            return

        if self.dryrun:
            log("Skipping log in for dry run...")
            self.authenticated = True
            return

        (username, password) = read_credentials()

        log("Logging in as %s..." % username)
        self.browser.open(self.bug_server_url + "index.cgi?GoAheadAndLogIn=1")
        self.browser.select_form(name="login")
        self.browser['Bugzilla_login'] = username
        self.browser['Bugzilla_password'] = password
        response = self.browser.submit()

        match = re.search("<title>(.+?)</title>", response.read())
        # If the resulting page has a title, and it contains the word "invalid" assume it's the login failure page.
        if match and re.search("Invalid", match.group(1), re.IGNORECASE):
            # FIXME: We could add the ability to try again on failure.
            error("Bugzilla login failed: %s" % match.group(1))

        self.authenticated = True
Example #6
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 = raw_input("Are you sure?  Type \"yes\" to continue: ")
         if (response != "yes"):
             error("User declined.")
     log("Running WebKit %s." % self.name)
Example #7
0
 def run(self, state):
     if not self._options.confirm:
         return
     diff = self.diff(state)
     self._tool.user.page(diff)
     if not self._tool.user.confirm():
         error("User declined to continue.")
Example #8
0
    def authenticate(self):
        if self.authenticated:
            return

        if self.dryrun:
            log("Skipping log in for dry run...")
            self.authenticated = True
            return

        (username, password) = read_credentials()

        log("Logging in as %s..." % username)
        self.browser.open(self.bug_server_url + "index.cgi?GoAheadAndLogIn=1")
        self.browser.select_form(name="login")
        self.browser["Bugzilla_login"] = username
        self.browser["Bugzilla_password"] = password
        response = self.browser.submit()

        match = re.search("<title>(.+?)</title>", response.read())
        # If the resulting page has a title, and it contains the word "invalid" assume it's the login failure page.
        if match and re.search("Invalid", match.group(1), re.IGNORECASE):
            # FIXME: We could add the ability to try again on failure.
            error("Bugzilla login failed: %s" % match.group(1))

        self.authenticated = True
Example #9
0
 def ensure_clean_working_directory(self, force):
     if not force and not self.working_directory_is_clean():
         print self.run_command(self.status_command(), raise_on_failure=False)
         error("Working directory has modifications, pass --force-clean or --no-clean to continue.")
     
     log("Cleaning working directory")
     self.clean_working_directory()
Example #10
0
 def ensure_clean_working_directory(self, force):
     if not force and not self.working_directory_is_clean():
         print self.run_command(self.status_command(), raise_on_failure=False)
         error("Working directory has modifications, pass --force-clean or --no-clean to continue.")
     
     log("Cleaning working directory")
     self.clean_working_directory()
Example #11
0
 def wrapper(*args, **kwargs):
     try:
         return response(func(*args, **kwargs))
     except Error as e:
         return error(e.json())
     except Exception as e:
         logging.error(e)
         return error(Error.unhandled(e).json())
Example #12
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))
Example #13
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 = raw_input("Are you sure?  Type \"yes\" to continue: ")
         if (response != "yes"):
             error("User declined.")
     log("Running WebKit %s." % self.name)
Example #14
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 #15
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 #16
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 #17
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
Example #18
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
Example #19
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))
 def wrapper(*args, **kwargs):
     t = time.time()
     try:
         response = func(*args, **kwargs)
         logging.access(time.time() - t)
         return response
     except (bottle.HTTPError, bottle.HTTPResponse) as e:
         logging.access(time.time() - t)
         raise e
     except Exception as e:
         logging.error(e, time.time() - t)
         if config.debug:
             return templates.message(e.__class__.__name__,
                                      extract_traceback(e, '<br>').replace('\n', '<br>')).template()
         return templates.message("Возникла непредвиденная ошибка", "Сообщите нам об этом, пожалуйста.").template()
Example #21
0
 def wrapper(*args, **kwargs):
     t = time.time()
     try:
         response = func(*args, **kwargs)
         logging.access(time.time() - t)
         return response
     except (bottle.HTTPError, bottle.HTTPResponse) as e:
         logging.access(time.time() - t)
         raise e
     except Exception as e:
         logging.error(e, time.time() - t)
         if config.debug:
             return templates.message(
                 e.__class__.__name__,
                 extract_traceback(e, '<br>').replace('\n',
                                                      '<br>')).template()
         return templates.message(
             "Возникла непредвиденная ошибка",
             "Сообщите нам об этом, пожалуйста.").template()
Example #22
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 #23
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)
Example #24
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 #25
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 #26
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.short_bug_url_for_bug_id(bug_id),
                              tool.bugs.fetch_bug_dictionary(bug_id)["title"]))
        log("Revision: %s" % svn_revision)

        if options.open_bug:
            self._open_bug_in_web_browser(tool, bug_id)

        if needs_prompt:
            self._prompt_user_for_correctness(bug_id, svn_revision)

        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 #27
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)
Example #28
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())
Example #29
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 #30
0
 def commit_locally_with_message(self, message):
     error("Your source control manager does not support local commits.")
Example #31
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 #32
0
 def commit_locally_with_message(self, message):
     error("Your source control manager does not support local commits.")
Example #33
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())