Exemplo n.º 1
0
    def __init__(self, ui):
        """
        Constructor
        
        @param ui reference to the user interface object (UI.UserInterface)
        """
        super(VcsMercurialPlugin, self).__init__(ui)
        self.__ui = ui

        self.__mercurialDefaults = {
            "StopLogOnCopy": True,  # used in log browser
            "UseLogBrowser": True,
            "LogLimit": 20,
            "CommitMessages": 20,
            "PullUpdate": False,
            "PreferUnbundle": False,
            "ServerPort": 8000,
            "ServerStyle": "",
            "CleanupPatterns": "*.orig *.rej *~",
            "CreateBackup": False,
            "InternalMerge": False,
            "Encoding": "utf-8",
            "EncodingMode": "strict",
            "ConsiderHidden": False,
        }

        from VcsPlugins.vcsMercurial.ProjectHelper import HgProjectHelper
        self.__projectHelperObject = HgProjectHelper(None, None)
        try:
            e5App().registerPluginObject(pluginTypename,
                                         self.__projectHelperObject,
                                         pluginType)
        except KeyError:
            pass  # ignore duplicate registration
        readShortcuts(pluginName=pluginTypename)
Exemplo n.º 2
0
 def __init__(self, ui):
     """
     Constructor
     
     @param ui reference to the user interface object (UI.UserInterface)
     """
     super(VcsMercurialPlugin, self).__init__(ui)
     self.__ui = ui
     
     self.__mercurialDefaults = {
         "StopLogOnCopy": True,  # used in log browser
         "UseLogBrowser": True,
         "LogLimit": 20,
         "CommitMessages": 20,
         "PullUpdate": False,
         "PreferUnbundle": False,
         "ServerPort": 8000,
         "ServerStyle": "",
         "CleanupPatterns": "*.orig *.rej *~",
         "CreateBackup": False,
         "InternalMerge": False,
         "Encoding": "utf-8",
         "EncodingMode": "strict",
         "ConsiderHidden": False,
     }
     
     from VcsPlugins.vcsMercurial.ProjectHelper import HgProjectHelper
     self.__projectHelperObject = HgProjectHelper(None, None)
     try:
         e5App().registerPluginObject(
             pluginTypename, self.__projectHelperObject, pluginType)
     except KeyError:
         pass    # ignore duplicate registration
     readShortcuts(pluginName=pluginTypename)
Exemplo n.º 3
0
    def __init__(self, ui):
        """
        Constructor
        
        @param ui reference to the user interface object (UI.UserInterface)
        """
        super(VcsMercurialPlugin, self).__init__(ui)
        self.__ui = ui

        from VcsPlugins.vcsMercurial.ProjectHelper import HgProjectHelper
        self.__projectHelperObject = HgProjectHelper(None, None)
        try:
            e5App().registerPluginObject(pluginTypename,
                                         self.__projectHelperObject,
                                         pluginType)
        except KeyError:
            pass  # ignore duplicate registration
        readShortcuts(pluginName=pluginTypename)
Exemplo n.º 4
0
class VcsMercurialPlugin(QObject):
    """
    Class implementing the Mercurial version control plugin.
    """
    def __init__(self, ui):
        """
        Constructor
        
        @param ui reference to the user interface object (UI.UserInterface)
        """
        super(VcsMercurialPlugin, self).__init__(ui)
        self.__ui = ui
        
        self.__mercurialDefaults = {
            "StopLogOnCopy": True,  # used in log browser
            "UseLogBrowser": True,
            "LogLimit": 20,
            "CommitMessages": 20,
            "PullUpdate": False,
            "PreferUnbundle": False,
            "ServerPort": 8000,
            "ServerStyle": "",
            "CleanupPatterns": "*.orig *.rej *~",
            "CreateBackup": False,
            "InternalMerge": False,
            "Encoding": "utf-8",
            "EncodingMode": "strict",
            "ConsiderHidden": False,
        }
        
        from VcsPlugins.vcsMercurial.ProjectHelper import HgProjectHelper
        self.__projectHelperObject = HgProjectHelper(None, None)
        try:
            e5App().registerPluginObject(
                pluginTypename, self.__projectHelperObject, pluginType)
        except KeyError:
            pass    # ignore duplicate registration
        readShortcuts(pluginName=pluginTypename)
    
    def getProjectHelper(self):
        """
        Public method to get a reference to the project helper object.
        
        @return reference to the project helper object
        """
        return self.__projectHelperObject

    def initToolbar(self, ui, toolbarManager):
        """
        Public slot to initialize the VCS toolbar.
        
        @param ui reference to the main window (UserInterface)
        @param toolbarManager reference to a toolbar manager object
            (E5ToolBarManager)
        """
        if self.__projectHelperObject:
            self.__projectHelperObject.initToolbar(ui, toolbarManager)
    
    def activate(self):
        """
        Public method to activate this plugin.
        
        @return tuple of reference to instantiated viewmanager and
            activation status (boolean)
        """
        from VcsPlugins.vcsMercurial.hg import Hg
        self.__object = Hg(self, self.__ui)
        
        tb = self.__ui.getToolbar("vcs")[1]
        tb.setVisible(False)
        tb.setEnabled(False)
        
        tb = self.__ui.getToolbar("mercurial")[1]
        tb.setVisible(True)
        tb.setEnabled(True)
        
        return self.__object, True
    
    def deactivate(self):
        """
        Public method to deactivate this plugin.
        """
        self.__object = None
        
        tb = self.__ui.getToolbar("mercurial")[1]
        tb.setVisible(False)
        tb.setEnabled(False)
        
        tb = self.__ui.getToolbar("vcs")[1]
        tb.setVisible(True)
        tb.setEnabled(True)
    
    def getPreferences(self, key):
        """
        Public method to retrieve the various settings.
        
        @param key the key of the value to get
        @return the requested setting
        """
        if key in ["StopLogOnCopy", "UseLogBrowser", "PullUpdate",
                   "PreferUnbundle", "CreateBackup", "InternalMerge",
                   "ConsiderHidden"]:
            return Preferences.toBool(Preferences.Prefs.settings.value(
                "Mercurial/" + key, self.__mercurialDefaults[key]))
        elif key in ["LogLimit", "CommitMessages", "ServerPort"]:
            return int(Preferences.Prefs.settings.value(
                "Mercurial/" + key, self.__mercurialDefaults[key]))
        elif key in ["Commits"]:
            return Preferences.toList(Preferences.Prefs.settings.value(
                "Mercurial/" + key))
        else:
            return Preferences.Prefs.settings.value(
                "Mercurial/" + key, self.__mercurialDefaults[key])
    
    def setPreferences(self, key, value):
        """
        Public method to store the various settings.
        
        @param key the key of the setting to be set
        @param value the value to be set
        """
        Preferences.Prefs.settings.setValue("Mercurial/" + key, value)

    def getGlobalOptions(self):
        """
        Public method to build a list of global options.
        
        @return list of global options (list of string)
        """
        args = []
        if self.getPreferences("Encoding") != \
                self.__mercurialDefaults["Encoding"]:
            args.append("--encoding")
            args.append(self.getPreferences("Encoding"))
        if self.getPreferences("EncodingMode") != \
                self.__mercurialDefaults["EncodingMode"]:
            args.append("--encodingmode")
            args.append(self.getPreferences("EncodingMode"))
        if self.getPreferences("ConsiderHidden"):
            args.append("--hidden")
        return args
    
    def getConfigPath(self):
        """
        Public method to get the filename of the config file.
        
        @return filename of the config file (string)
        """
        return getConfigPath()
    
    def prepareUninstall(self):
        """
        Public method to prepare for an uninstallation.
        """
        e5App().unregisterPluginObject(pluginTypename)
    
    def prepareUnload(self):
        """
        Public method to prepare for an unload.
        """
        if self.__projectHelperObject:
            self.__projectHelperObject.removeToolbar(
                self.__ui, e5App().getObject("ToolbarManager"))
        e5App().unregisterPluginObject(pluginTypename)
Exemplo n.º 5
0
class VcsMercurialPlugin(QObject):
    """
    Class implementing the Mercurial version control plugin.
    """
    def __init__(self, ui):
        """
        Constructor
        
        @param ui reference to the user interface object (UI.UserInterface)
        """
        super(VcsMercurialPlugin, self).__init__(ui)
        self.__ui = ui

        self.__mercurialDefaults = {
            "StopLogOnCopy": True,  # used in log browser
            "UseLogBrowser": True,
            "LogLimit": 20,
            "CommitMessages": 20,
            "PullUpdate": False,
            "PreferUnbundle": False,
            "ServerPort": 8000,
            "ServerStyle": "",
            "CleanupPatterns": "*.orig *.rej *~",
            "CreateBackup": False,
            "InternalMerge": False,
            "Encoding": "utf-8",
            "EncodingMode": "strict",
            "ConsiderHidden": False,
        }

        from VcsPlugins.vcsMercurial.ProjectHelper import HgProjectHelper
        self.__projectHelperObject = HgProjectHelper(None, None)
        try:
            e5App().registerPluginObject(pluginTypename,
                                         self.__projectHelperObject,
                                         pluginType)
        except KeyError:
            pass  # ignore duplicate registration
        readShortcuts(pluginName=pluginTypename)

    def getProjectHelper(self):
        """
        Public method to get a reference to the project helper object.
        
        @return reference to the project helper object
        """
        return self.__projectHelperObject

    def initToolbar(self, ui, toolbarManager):
        """
        Public slot to initialize the VCS toolbar.
        
        @param ui reference to the main window (UserInterface)
        @param toolbarManager reference to a toolbar manager object
            (E5ToolBarManager)
        """
        if self.__projectHelperObject:
            self.__projectHelperObject.initToolbar(ui, toolbarManager)

    def activate(self):
        """
        Public method to activate this plugin.
        
        @return tuple of reference to instantiated viewmanager and
            activation status (boolean)
        """
        from VcsPlugins.vcsMercurial.hg import Hg
        self.__object = Hg(self, self.__ui)

        tb = self.__ui.getToolbar("vcs")[1]
        tb.setVisible(False)
        tb.setEnabled(False)

        tb = self.__ui.getToolbar("mercurial")[1]
        tb.setVisible(True)
        tb.setEnabled(True)

        return self.__object, True

    def deactivate(self):
        """
        Public method to deactivate this plugin.
        """
        self.__object = None

        tb = self.__ui.getToolbar("mercurial")[1]
        tb.setVisible(False)
        tb.setEnabled(False)

        tb = self.__ui.getToolbar("vcs")[1]
        tb.setVisible(True)
        tb.setEnabled(True)

    def getPreferences(self, key):
        """
        Public method to retrieve the various settings.
        
        @param key the key of the value to get
        @return the requested setting
        """
        if key in [
                "StopLogOnCopy", "UseLogBrowser", "PullUpdate",
                "PreferUnbundle", "CreateBackup", "InternalMerge",
                "ConsiderHidden"
        ]:
            return Preferences.toBool(
                Preferences.Prefs.settings.value(
                    "Mercurial/" + key, self.__mercurialDefaults[key]))
        elif key in ["LogLimit", "CommitMessages", "ServerPort"]:
            return int(
                Preferences.Prefs.settings.value(
                    "Mercurial/" + key, self.__mercurialDefaults[key]))
        elif key in ["Commits"]:
            return Preferences.toList(
                Preferences.Prefs.settings.value("Mercurial/" + key))
        else:
            return Preferences.Prefs.settings.value(
                "Mercurial/" + key, self.__mercurialDefaults[key])

    def setPreferences(self, key, value):
        """
        Public method to store the various settings.
        
        @param key the key of the setting to be set
        @param value the value to be set
        """
        Preferences.Prefs.settings.setValue("Mercurial/" + key, value)

    def getGlobalOptions(self):
        """
        Public method to build a list of global options.
        
        @return list of global options (list of string)
        """
        args = []
        if self.getPreferences("Encoding") != \
                self.__mercurialDefaults["Encoding"]:
            args.append("--encoding")
            args.append(self.getPreferences("Encoding"))
        if self.getPreferences("EncodingMode") != \
                self.__mercurialDefaults["EncodingMode"]:
            args.append("--encodingmode")
            args.append(self.getPreferences("EncodingMode"))
        if self.getPreferences("ConsiderHidden"):
            args.append("--hidden")
        return args

    def getConfigPath(self):
        """
        Public method to get the filename of the config file.
        
        @return filename of the config file (string)
        """
        return getConfigPath()

    def prepareUninstall(self):
        """
        Public method to prepare for an uninstallation.
        """
        e5App().unregisterPluginObject(pluginTypename)

    def prepareUnload(self):
        """
        Public method to prepare for an unload.
        """
        if self.__projectHelperObject:
            self.__projectHelperObject.removeToolbar(
                self.__ui,
                e5App().getObject("ToolbarManager"))
        e5App().unregisterPluginObject(pluginTypename)