def __init__(self, path): InterfaceNonView.__init__(self) log.debug("incoming path: %s"%path) self.path = path self.vcs = rabbitvcs.vcs.VCS() self.svn = self.vcs.svn() status = self.svn.status(self.path) if status.simple_content_status() != rabbitvcs.vcs.status.status_complicated: log.debug("The specified file is not conflicted. There is nothing to do.") self.close() return filename = os.path.basename(path) dialog = rabbitvcs.ui.dialog.ConflictDecision(filename) action = dialog.run() dialog.destroy() if action == -1: #Cancel pass elif action == 0: #Accept Mine working = self.get_working_path(path) shutil.copyfile(working, path) self.svn.resolve(path) elif action == 1: #Accept Theirs ancestor, theirs = self.get_revisioned_paths(path) shutil.copyfile(theirs, path) self.svn.resolve(path) elif action == 2: #Merge Manually working = self.get_working_path(path) ancestor, theirs = self.get_revisioned_paths(path) log.debug("launching merge tool with base: %s, mine: %s, theirs: %s, merged: %s"%(ancestor, working, theirs, path)) rabbitvcs.util.helper.launch_merge_tool(base=ancestor, mine=working, theirs=theirs, merged=path) dialog = rabbitvcs.ui.dialog.MarkResolvedPrompt() mark_resolved = dialog.run() dialog.destroy() if mark_resolved == 1: self.svn.resolve(path) self.close()
def get_log_message(self): """ A callback method that retrieves a supplied log message. Returns a list where the first element is True/False. Returning true tells the action to continue, false tells it to cancel. The second element is the log message, which is specified by self.message. self.message is set by calling the self.set_log_message() method from the UI interface class. @rtype: (boolean, string) @return: (True=continue/False=cancel, log message) """ if self.message is None: gtk.gdk.threads_enter() dialog = rabbitvcs.ui.dialog.TextChange(_("Log Message")) result = dialog.run() gtk.gdk.threads_leave() should_continue = (result[0] == gtk.RESPONSE_OK) return should_continue, result[1].encode("utf-8") else: return True, self.message.encode("utf-8")
def get_client_cert(self, realm, may_save): """ A callback method that is used to get an ssl certificate. The dialog must be called from within a threaded block, otherwise it will not be responsive. @type realm: string @param realm: The certificate realm. @type may_save: boolean @param may_save: Whether or not the passphrase can be saved. @rtype: (boolean, string, boolean) @return: (True=continue/False=cancel, password, may save) """ gtk.gdk.threads_enter() dialog = rabbitvcs.ui.dialog.SSLClientCertPrompt( realm, may_save ) result = dialog.run() gtk.gdk.threads_leave() return result
def get_user(self): gtk.gdk.threads_enter() dialog = rabbitvcs.ui.dialog.NameEmailPrompt() result = dialog.run() gtk.gdk.threads_leave() return result
def browser_copy_to(self, data=None, user_data=None): from rabbitvcs.ui.dialog import OneLineTextChange dialog = OneLineTextChange( _("Where do you want to copy the selection?"), _("New Location:"), self.caller.get_url()) result = dialog.run() if result is None: return (response, new_url) = result if response == Gtk.ResponseType.CANCEL: return sources = self.__generate_sources_list() self.caller.action = rabbitvcs.ui.action.SVNAction(self.svn, notification=False) self.caller.action.append(self.svn.copy_all, sources, new_url, copy_as_child=True) self.caller.action.append(self.svn.list, self.caller.get_url(), recurse=False) self.caller.action.append(self.caller.populate_table, 1) self.caller.action.schedule()
def browser_copy_to(self, data=None, user_data=None): from rabbitvcs.ui.dialog import OneLineTextChange dialog = OneLineTextChange( _("Where do you want to copy the selection?"), _("New Location:"), self.caller.get_url() ) result = dialog.run() if result is None: return (response, new_url) = result if response == Gtk.ResponseType.CANCEL: return sources = self.__generate_sources_list() self.caller.action = rabbitvcs.ui.action.SVNAction( self.svn, notification=False ) self.caller.action.append(self.svn.copy_all, sources, new_url, copy_as_child=True) self.caller.action.append(self.svn.list, self.caller.get_url(), recurse=False) self.caller.action.append(self.caller.populate_table, 1) self.caller.action.schedule()
def saveas(self, path=None): if path is None: from rabbitvcs.ui.dialog import FileSaveAs dialog = FileSaveAs() path = dialog.run() if path is not None: fh = open(path, "w") fh.write(self.table.generate_string_from_data()) fh.close()
def delete_properties(self, names): recursive = False if (os.path.isdir(self.path)): dialog = rabbitvcs.ui.dialog.Confirmation(RECURSIVE_DELETE_MSG) recursive = dialog.run() for name in names: self.svn.propdel(self.path, name, recurse=recursive) self.refresh()
def delete_properties(self, names): recursive = False if(os.path.isdir(self.path)): dialog = rabbitvcs.ui.dialog.Confirmation(RECURSIVE_DELETE_MSG) recursive = dialog.run() for name in names: self.svn.propdel(self.path, name, recurse=recursive) self.refresh()
def __init__(self, path): InterfaceNonView.__init__(self) self.path = path self.vcs = rabbitvcs.vcs.VCS() self.svn = self.vcs.svn() status = self.svn.status(self.path) if status.simple_content_status() != rabbitvcs.vcs.status.status_complicated: log.debug("The specified file is not conflicted. There is nothing to do.") self.close() return filename = os.path.basename(path) dialog = rabbitvcs.ui.dialog.ConflictDecision(filename) (action, mark_resolved) = dialog.run() dialog.destroy() if action == -1: #Cancel pass elif action == 0: #Accept Mine working = self.get_working_path(path) shutil.copyfile(working, path) if mark_resolved: self.svn.resolve(path) elif action == 1: #Accept Theirs head = self.get_head_path(path) shutil.copyfile(head, path) if mark_resolved: self.svn.resolve(path) elif action == 2: #Merge Manually head = self.get_head_path(path) working = self.get_working_path(path) shutil.copyfile(working, path) rabbitvcs.util.helper.launch_merge_tool(path, head) if mark_resolved: self.svn.resolve(path) self.close()
def edit_property(self, name=""): value = self.svn.propget(self.path, name) dialog = rabbitvcs.ui.dialog.Property(name, value) name,value,recurse = dialog.run() if name: success = self.svn.propset(self.path, name, value, overwrite=True, recurse=False) if not success: rabbitvcs.ui.dialog.MessageBox(_("Unable to set new value for property.")) self.refresh()
def create_repository_folder(self, data=None, user_data=None): from rabbitvcs.ui.dialog import NewFolder dialog = NewFolder() result = dialog.run() if result is None: return (folder_name, log_message) = result new_url = self.paths[0].rstrip("/") + "/" + folder_name self.caller.action = rabbitvcs.ui.action.SVNAction(self.svn, notification=False) self.caller.action.append(self.svn.mkdir, new_url, log_message) self.caller.action.append(self.svn.list, self.paths[0], recurse=False) self.caller.action.append(self.caller.populate_table, 1) self.caller.action.start()
def create_folder(self, where): from rabbitvcs.ui.dialog import NewFolder dialog = NewFolder() result = dialog.run() if result is None: return (folder_name, log_message) = result new_url = where.rstrip("/") + "/" + folder_name self.action = rabbitvcs.ui.action.SVNAction(self.svn, notification=False) self.action.append(self.svn.mkdir, new_url, log_message) self.action.append(self.svn.list, where, recurse=False) self.action.append(self.populate_table, 1) self.action.schedule()
def edit_property(self, name=""): value = self.svn.propget(self.path, name) dialog = rabbitvcs.ui.dialog.Property(name, value) name, value, recurse = dialog.run() if name: success = self.svn.propset(self.path, name, value, overwrite=True, recurse=False) if not success: rabbitvcs.ui.dialog.MessageBox( _("Unable to set new value for property.")) self.refresh()
def create_repository_folder(self, data=None, user_data=None): from rabbitvcs.ui.dialog import NewFolder dialog = NewFolder() result = dialog.run() if result is None: return (folder_name, log_message) = result new_url = self.paths[0].rstrip("/") + "/" + folder_name self.caller.action = rabbitvcs.ui.action.SVNAction( self.svn, notification=False ) self.caller.action.append(self.svn.mkdir, new_url, log_message) self.caller.action.append(self.svn.list, self.paths[0], recurse=False) self.caller.action.append(self.caller.populate_table, 1) self.caller.action.schedule()
def get_ssl_trust(self, data): """ A callback method that requires the user to either accept or deny a certificate from an ssl secured repository. It opens a dialog that shows the user information about the ssl certificate and then gives them the option of denying, accepting, or accepting once. The dialog must be called from within a threaded block, otherwise it will not be responsive. @type data: dictionary @param data: A dictionary with SSL certificate info. @rtype: (boolean, int, boolean) @return: (True=Accept/False=Deny, number of accepted failures, remember) """ gtk.gdk.threads_enter() if not data: return (False, 0, False) dialog = rabbitvcs.ui.dialog.Certificate( data["realm"], data["hostname"], data["issuer_dname"], data["valid_from"], data["valid_until"], data["finger_print"] ) result = dialog.run() gtk.gdk.threads_leave() if result == 0: #Deny return (False, 0, False) elif result == 1: #Accept Once return (True, data["failures"], False) elif result == 2: #Accept Forever return (True, data["failures"], True)
def choose_patch_path(self): path = "" dialog = gtk.FileChooserDialog(_("Create Patch"), None, gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)) dialog.set_do_overwrite_confirmation(True) dialog.set_default_response(gtk.RESPONSE_OK) dialog.set_current_folder_uri( get_common_directory(self.paths).replace("file://", "")) response = dialog.run() if response == gtk.RESPONSE_OK: path = dialog.get_filename() dialog.destroy() return path
def choose_patch_path(self): path = "" dialog = Gtk.FileChooserDialog(title=_("Create Patch"), parent=None, action=Gtk.FileChooserAction.SAVE) dialog.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL) dialog.add_button(_("_Create"), Gtk.ResponseType.OK) dialog.set_do_overwrite_confirmation(True) dialog.set_default_response(Gtk.ResponseType.OK) dialog.set_current_folder_uri( helper.get_common_directory(self.paths).replace("file://", "")) response = dialog.run() if response == Gtk.ResponseType.OK: path = dialog.get_filename() dialog.destroy() return path
def get_login(self, realm, username, may_save): """ A callback method that requests a username/password to login to a password-protected repository. This method runs the Authentication dialog, which provides a username, password, and saving widget. The dialog returns a tuple, which is returned directly to the VCS caller. If the login fails greater than three times, cancel the action. The dialog must be called from within a threaded block, otherwise it will not be responsive. @type realm: string @param realm: The realm of the repository. @type username: string @param username: Username passed by the vcs caller. @type may_save: boolean @param may_save: Whether or not the authentication can be saved. @rtype: (boolean, string, string, boolean) @return: (True=continue/False=cancel, username,password, may_save) """ if self.login_tries >= 3: return (False, "", "", False) gtk.gdk.threads_enter() dialog = rabbitvcs.ui.dialog.Authentication( realm, may_save ) result = dialog.run() gtk.gdk.threads_leave() if result is not None: self.login_tries += 1 return result
def choose_patch_path(self): path = "" dialog = gtk.FileChooserDialog( _("Create Patch"), None, gtk.FILE_CHOOSER_ACTION_SAVE,(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK)) dialog.set_do_overwrite_confirmation(True) dialog.set_default_response(gtk.RESPONSE_OK) dialog.set_current_folder_uri( get_common_directory(self.paths).replace("file://", "") ) response = dialog.run() if response == gtk.RESPONSE_OK: path = dialog.get_filename() dialog.destroy() return path
def choose_patch_path(self): path = "" dialog = Gtk.FileChooserDialog( title = _("Create Patch"), parent = None, action = Gtk.FileChooserAction.SAVE) dialog.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL) dialog.add_button(_("_Create"), Gtk.ResponseType.OK) dialog.set_do_overwrite_confirmation(True) dialog.set_default_response(Gtk.ResponseType.OK) dialog.set_current_folder_uri( helper.get_common_directory(self.paths).replace("file://", "") ) response = dialog.run() if response == Gtk.ResponseType.OK: path = dialog.get_filename() dialog.destroy() return path
def browser_move_to(self, data=None, user_data=None): from rabbitvcs.ui.dialog import OneLineTextChange dialog = OneLineTextChange( _("Where do you want to move the selection?"), _("New Location:"), self.caller.get_url() ) result = dialog.run() if result is None: return (response, new_url) = result if response == gtk.RESPONSE_CANCEL: return self.caller.action = rabbitvcs.ui.action.SVNAction( self.svn, notification=False ) self.caller.action.append(self.svn.move_all, self.paths, new_url, move_as_child=True) self.caller.action.append(self.svn.list, self.caller.get_url(), recurse=False) self.caller.action.append(self.caller.populate_table, 1) self.caller.action.start()
def rename(self, data=None, user_data=None): (base, filename) = os.path.split(self.paths[0]) from rabbitvcs.ui.dialog import OneLineTextChange dialog = OneLineTextChange(_("Rename"), _("New Name:"), filename) (result, new_name) = dialog.run() if result == Gtk.ResponseType.CANCEL: return new_url = base.rstrip("/") + "/" + new_name path_to_refresh = self.caller.get_url() if self.paths[0] == path_to_refresh: path_to_refresh = new_url self.__update_browser_url(path_to_refresh) self.caller.action = rabbitvcs.ui.action.SVNAction( self.svn, notification=False ) self.caller.action.append(self.svn.move, self.paths[0], new_url) self.caller.action.append(self.svn.list, path_to_refresh, recurse=False) self.caller.action.append(self.caller.populate_table, 1) self.caller.action.schedule()
def rename(self, data=None, user_data=None): (base, filename) = os.path.split(self.paths[0]) from rabbitvcs.ui.dialog import OneLineTextChange dialog = OneLineTextChange(_("Rename"), _("New Name:"), filename) (result, new_name) = dialog.run() if result == Gtk.ResponseType.CANCEL: return new_url = base.rstrip("/") + "/" + new_name path_to_refresh = self.caller.get_url() if self.paths[0] == path_to_refresh: path_to_refresh = new_url self.__update_browser_url(path_to_refresh) self.caller.action = rabbitvcs.ui.action.SVNAction(self.svn, notification=False) self.caller.action.append(self.svn.move, self.paths[0], new_url) self.caller.action.append(self.svn.list, path_to_refresh, recurse=False) self.caller.action.append(self.caller.populate_table, 1) self.caller.action.schedule()
def on_new_clicked(self, widget): dialog = rabbitvcs.ui.dialog.Property() name, value, recurse = dialog.run() if name: self.table.append([recurse, name, value])
def on_edit_clicked(self, widget): (recurse, name, value) = self.get_selected_name_value() dialog = rabbitvcs.ui.dialog.Property(name, value) name, value, recurse = dialog.run() if name: self.set_selected_name_value(name, value, recurse)
def on_previous_messages_clicked(self, widget, data=None): dialog = rabbitvcs.ui.dialog.PreviousMessages() message = dialog.run() if message is not None: self.message.set_text(message)
def on_new_clicked(self, widget): dialog = rabbitvcs.ui.dialog.Property() name,value,recurse = dialog.run() if name: self.table.append([recurse,name,value])
def on_edit_clicked(self, widget): (recurse,name,value) = self.get_selected_name_value() dialog = rabbitvcs.ui.dialog.Property(name, value) name,value,recurse = dialog.run() if name: self.set_selected_name_value(name, value, recurse)