def update_widgets(self): self.log_table.clear() repository = "" branch = "" if not self.git_svn: repository = self.repository_selector.repository_opt.get_active_text( ) branch = self.repository_selector.branch_opt.get_active_text() if not repository or not branch: if self.git_svn: pass else: self.get_widget("ok").set_sensitive(False) return has_commits = False for item in self.push_log: self.log_table.append([ helper.format_datetime(item.date, self.datetime_format), helper.format_long_text(item.message.rstrip("\n")) ]) has_commits = True self.get_widget("ok").set_sensitive(True) if not has_commits: self.get_widget("status").set_text(_("No commits found"))
def generate_string_from_result(self): blamedict = self.action.get_result(0) text = "" for item in blamedict: text += "%s\t%s\t%s\t%s\t%s\n" % ( str(item["number"]), item["revision"][:7], item["author"], helper.format_datetime(item["date"], self.datetime_format), item["line"]) return text
def update_branch_info(self): from_branch = self.from_branches.get_revision_object() if from_branch.value: log = self.git.log(self.path, limit=1, revision=from_branch, showtype="branch") if log: from_info = log[0] self.info['from']['author'].set_text(from_info.author) self.info['from']['date'].set_text(helper.format_datetime(from_info.date)) self.info['from']['revision'].set_text(helper.to_text(from_info.revision)[0:7]) self.info['from']['message'].set_text(helper.html_escape(helper.format_long_text(from_info.message, 500)))
def date_filter(self, row, column, user_data=None): """ Table filter to convert the item date to something readable """ if row[0] == "..": return "" if row[column]: change_time = datetime.fromtimestamp(float(row[column])) return helper.format_datetime(change_time) return str(row[column])
def update_branch_info(self): from_branch = self.from_branches.get_revision_object() if from_branch.value: log = self.git.log(self.path, limit=1, revision=from_branch, showtype="branch") if log: from_info = log[0] self.info['from']['author'].set_text(from_info.author) self.info['from']['date'].set_text( helper.format_datetime(from_info.date)) self.info['from']['revision'].set_text( helper.to_text(from_info.revision)[0:7]) self.info['from']['message'].set_text( helper.html_escape( helper.format_long_text(from_info.message, 500)))
def populate_table(self): blamedict = self.action.get_result(0) lines = highlight(self.path, [item["line"] for item in blamedict]) self.table.clear() for i, item in enumerate(blamedict): revision = item["revision"][:7] author = S(item["author"].strip()) author_color = self.author_background.get(author, "#FFFFFF") try: revision_color = self.log_by_revision[revision].background except KeyError: revision_color = "#FFFFFF" self.table.append([ revision, author, helper.format_datetime(item["date"], self.datetime_format), str(item["number"]), lines[i], revision_color, author_color ])
def show_detail(self, tag_name): self.selected_tag = None for item in self.tag_list: if S(item.name) == tag_name: self.selected_tag = item break self.save_button.set_label(_("Save")) if self.selected_tag: self.tag_entry.set_text(S(self.selected_tag.name).display()) self.revision_label.set_text(S(self.selected_tag.sha).display()) self.message_label.set_text( S(self.selected_tag.message).display().rstrip("\n")) self.tagger_label.set_text(S(self.selected_tag.tagger).display()) self.date_label.set_text( helper.format_datetime( datetime.fromtimestamp(self.selected_tag.tag_time), self.datetime_format)) self.show_rows(self.view_rows) self.get_widget("detail_label").set_markup(_("<b>Tag Detail</b>"))
def update_widgets(self): self.log_table.clear() repository = self.repository_selector.repository_opt.get_active_text() branch = self.repository_selector.branch_opt.get_active_text() if not repository or not branch: self.get_widget("ok").set_sensitive(False) return has_commits = False for item in self.push_log: self.log_table.append([ helper.format_datetime(item.date), helper.format_long_text(item.message.rstrip("\n")) ]) has_commits = True self.get_widget("ok").set_sensitive(True) if not has_commits: self.get_widget("status").set_text(_("No commits found"))
def blame_info(self, item): revision = item["revision"].number if revision <= 0: return ("", "", "") revision = str(revision) # remove fractional seconds and timezone information from # the end of the string provided by pysvn: # * timezone should be always "Z" (for UTC), "%Z" is not yet # yet supported by strptime # * fractional could be parsed with "%f" since python 2.6 # but this precision is not needed anyway # * the datetime module does not include strptime until python 2.4 # so this workaround is required for now datestr = item["date"][0:-8] try: date = datetime(*time.strptime(datestr, "%Y-%m-%dT%H:%M:%S")[:-2]) date = helper.format_datetime(date, self.datetime_format) except: date = "" return revision, date, S(item["author"].strip())
def __init__(self, base_dir=None): """ Provides an interface to the settings library. """ InterfaceView.__init__(self, "settings", "Settings") self.checker_service = None self.settings = rabbitvcs.util.settings.SettingsManager() self.get_widget("enable_attributes").set_active( int(self.settings.get("general", "enable_attributes"))) self.get_widget("enable_emblems").set_active( int(self.settings.get("general", "enable_emblems"))) self.get_widget("enable_recursive").set_active( int(self.settings.get("general", "enable_recursive"))) self.get_widget("enable_highlighting").set_active( int(self.settings.get("general", "enable_highlighting"))) self.get_widget("enable_colorize").set_active( int(self.settings.get("general", "enable_colorize"))) self.get_widget("show_debug").set_active( int(self.settings.get("general", "show_debug"))) self.get_widget("enable_subversion").set_active( int(self.settings.get("HideItem", "svn")) == 0) self.get_widget("enable_git").set_active( int(self.settings.get("HideItem", "git")) == 0) dtfs = [] dt = datetime.datetime.today() # Disambiguate day. if dt.day <= 12: dt = datetime.datetime(dt.year, dt.month, dt.day + 12, dt.hour, dt.minute, dt.second) for format, label in self.dtformats: if label is None: label = helper.format_datetime(dt, format) dtfs.append([format, label]) self.datetime_format = rabbitvcs.ui.widget.ComboBox( self.get_widget("datetime_format"), dtfs, 2, 1) self.datetime_format.set_active_from_value( self.settings.get("general", "datetime_format")) self.default_commit_message = rabbitvcs.ui.widget.TextView( self.get_widget("default_commit_message")) self.default_commit_message.set_text( S(self.settings.get_multiline("general", "default_commit_message")).display()) self.get_widget("diff_tool").set_text( S(self.settings.get("external", "diff_tool")).display()) self.get_widget("diff_tool_swap").set_active( int(self.settings.get("external", "diff_tool_swap"))) self.get_widget("merge_tool").set_text( S(self.settings.get("external", "merge_tool")).display()) self.get_widget("cache_number_repositories").set_text( S(self.settings.get("cache", "number_repositories")).display()) self.get_widget("cache_number_messages").set_text( S(self.settings.get("cache", "number_messages")).display()) self.logging_type = rabbitvcs.ui.widget.ComboBox( self.get_widget("logging_type"), ["None", "Console", "File", "Both"]) val = self.settings.get("logging", "type") if not val: val = "Console" self.logging_type.set_active_from_value(val) self.logging_level = rabbitvcs.ui.widget.ComboBox( self.get_widget("logging_level"), ["Debug", "Info", "Warning", "Error", "Critical"]) val = self.settings.get("logging", "level") if not val: val = "Debug" self.logging_level.set_active_from_value(val) # Git Configuration Editor show_git = False self.file_editor = None if base_dir: vcs = rabbitvcs.vcs.VCS() git_config_files = [] if vcs.is_in_a_or_a_working_copy(base_dir) and vcs.guess( base_dir)["vcs"] == rabbitvcs.vcs.VCS_GIT: git = vcs.git(base_dir) git_config_files = git.get_config_files(base_dir) self.file_editor = rabbitvcs.ui.widget.MultiFileTextEditor( self.get_widget("git_config_container"), _("Config file:"), git_config_files, git_config_files, show_add_line=False) show_git = True if show_git: self.get_widget("pages").get_nth_page(5).show() else: self.get_widget("pages").get_nth_page(5).hide() self._populate_checker_tab()
def on_ok_clicked(self, widget, data=None): items = self.files_table.get_activated_rows(1) if len(items) == 0: self.close() return if self.get_widget("toggle_commit_and_push").get_active(): message = self.git.get_not_pushed_inform("message") rev = self.git.get_not_pushed_inform("rev") date = self.git.get_not_pushed_inform("date") commit_num = len(message) if self.git_svn == False: if self.repository_selector == None: self.repository_selector = rabbitvcs.ui.widget.GitRepositorySelector( self.get_widget("repository_container"), self.git) else: self.get_widget("repository_container").show() if commit_num > 0: txt = "Committed revision already exist.\nDo you want to push all?\n\n" for i in range(commit_num): d = datetime.datetime.strptime(date[i], "%Y-%m-%d %H:%M:%S") dt = helper.format_datetime(d, self.datetime_format) txt += "{} | {} ({})\n".format(dt, message[i], rev[i][:8]) confirmation = rabbitvcs.ui.dialog.Confirmation(_(txt)) confirmation.get_widget("confirm_cancel").set_label( _("_Cancel")) confirmation.get_widget("confirm_ok").set_label(_("_OK")) if confirmation.run() != Gtk.ResponseType.OK: return self.hide() staged = 0 for item in items: staged += 1 ticks = staged + len(items) * 2 self.action = rabbitvcs.ui.action.GitAction( self.git, register_gtk_quit=self.gtk_quit_is_set()) self.action.set_pbar_ticks(ticks) self.action.append(self.action.set_header, _("Commit")) self.action.append(self.action.set_status, _("Running Commit Command...")) self.action.append(helper.save_log_message, self.message.get_text()) self.action.append(self.git.add_commit, items, self.message.get_text()) self.action.append(self.action.set_status, _("Completed Commit")) if self.commit_and_push: self.action.append(self.action.set_header, _("Commit & Push")) self.action.append(self.action.set_status, _("Running Push Command...")) if self.git_svn: self.action.append(self.git.git_svn_push, ) else: self.action.append(self.git.push, repository=self.repository_selector. repository_opt.get_active_text(), refspec=self.repository_selector.branch_opt. get_active_text()) self.action.append(self.action.set_status, _("Completed Push")) self.action.append(self.action.finish) self.action.schedule()