Ejemplo n.º 1
0
    def update(self):
        """merge modifiactions since last update into working copy"""
        print "update"
        if self.unresolved_conflicts():
            return
        layer = QgsMapLayerRegistry.instance().mapLayer(self.current_layers[0])
        uri = QgsDataSourceURI(layer.source())

        late_by = 0

        if layer.providerType() == "spatialite":
            late_by = versioning_base.late(uri.database(), self.pg_conn_info())
        else:  # postgres
            late_by = versioning_base.pg_late(self.pg_conn_info(),
                                              uri.schema())
        if late_by:
            if layer.providerType() == "spatialite":
                versioning_base.update(uri.database(), self.pg_conn_info())
                rev = versioning_base.revision(uri.database())
            else:  # postgres
                versioning_base.pg_update(uri.connectionInfo(), uri.schema())
                rev = versioning_base.pg_revision(uri.connectionInfo(),
                                                  uri.schema())

            # Force refresh of map
            if self.iface.mapCanvas().isCachingEnabled():
                self.iface.mapCanvas().clearCache()
                self.iface.mapCanvas().refresh()
            else:
                self.iface.mapCanvas().refresh()

            # Force refresh of rev number in menu text
            if layer.providerType() == "spatialite":
                self.info.setText(uri.database().split("/")[-1] +
                                  ' <b>working rev</b>=' + str(rev))
            else:
                self.info.setText(uri.database() + ' <b>working rev</b>=' +
                                  str(rev))

            if not self.unresolved_conflicts():
                QMessageBox.warning(
                    self.iface.mainWindow(), "Warning",
                    "Working copy was late by " + str(late_by) +
                    " revision(s).\n"
                    "Now up to date with remote revision " + str(rev - 1) +
                    ".")
        else:
            if layer.providerType() == "spatialite":
                rev = versioning_base.revision(uri.database())
            else:  # postgres
                rev = versioning_base.pg_revision(uri.connectionInfo(),
                                                  uri.schema())
            QMessageBox.information(
                self.iface.mainWindow(), "Info", "Working "
                "copy already up to date with remote revision " +
                str(rev - 1) + ".")
Ejemplo n.º 2
0
    def commit(self):
        """merge modifiactions into database"""
        print "commit"
        if self.unresolved_conflicts():
            return

        layer = QgsMapLayerRegistry.instance().mapLayer(self.current_layers[0])
        uri = QgsDataSourceURI(layer.source())

        late_by = 0
        if layer.providerType() == "spatialite":
            late_by = versioning_base.late(uri.database(), self.pg_conn_info())
        else:  #postgres
            late_by = versioning_base.pg_late(self.pg_conn_info(),
                                              uri.schema())

        if late_by:
            QMessageBox.warning(
                self.iface.mainWindow(), "Warning",
                "This working copy is not up to date (late by " +
                str(late_by) + " commit(s)).\n\n"
                "Please update before commiting your modifications")
            print "aborted"
            return

        # time to get the commit message
        if not self.q_commit_msg_dlg.exec_():
            return
        commit_msg = self.commit_msg_dlg.commitMessage.document().toPlainText()
        if not commit_msg:
            QMessageBox.warning(self.iface.mainWindow(), "Warning",
                                "No commit message, aborting commit")
            print "aborted"
            return

        nb_of_updated_layer = 0
        rev = 0
        if layer.providerType() == "spatialite":
            nb_of_updated_layer = versioning_base.commit(
                uri.database(), commit_msg, self.pg_conn_info())
            rev = versioning_base.revision(uri.database())
        else:  # postgres
            nb_of_updated_layer = versioning_base.pg_commit(
                uri.connectionInfo(), uri.schema(), commit_msg)
            rev = versioning_base.pg_revision(uri.connectionInfo(),
                                              uri.schema())

        if nb_of_updated_layer:
            QMessageBox.information(
                self.iface.mainWindow(), "Info",
                "You have successfully commited revision " + str(rev))
        else:
            QMessageBox.information(self.iface.mainWindow(), "Info",
                                    "There was no modification to commit")
Ejemplo n.º 3
0
    def commit(self):
        """merge modifiactions into database"""
        print "commit"
        if self.unresolved_conflicts():
            return

        layer = QgsMapLayerRegistry.instance().mapLayer(
                self.current_layers[0] )
        uri = QgsDataSourceURI(layer.source())

        late_by = 0
        if layer.providerType() == "spatialite":
            late_by = versioning_base.late(
                    uri.database(), self.pg_conn_info() )
        else:#postgres
            late_by = versioning_base.pg_late(
                    self.pg_conn_info(), uri.schema() )

        if late_by:
            QMessageBox.warning(self.iface.mainWindow(), "Warning",
                    "This working copy is not up to date (late by "
                    +str(late_by)+" commit(s)).\n\n"
                    "Please update before commiting your modifications")
            print "aborted"
            return

        # time to get the commit message
        if not self.q_commit_msg_dlg.exec_():
            return
        commit_msg = self.commit_msg_dlg.commitMessage.document().toPlainText()
        if not commit_msg:
            QMessageBox.warning(self.iface.mainWindow(), "Warning",
                    "No commit message, aborting commit")
            print "aborted"
            return

        nb_of_updated_layer = 0
        rev = 0
        if layer.providerType() == "spatialite":
            nb_of_updated_layer = versioning_base.commit( uri.database(),
                    commit_msg, self.pg_conn_info() )
            rev = versioning_base.revision(uri.database())
        else: # postgres
            nb_of_updated_layer = versioning_base.pg_commit(
                    uri.connectionInfo(), uri.schema(), commit_msg )
            rev = versioning_base.pg_revision(
                    uri.connectionInfo(), uri.schema())

        if nb_of_updated_layer:
            QMessageBox.information(self.iface.mainWindow(), "Info",
                    "You have successfully commited revision "+str( rev ) )
        else:
            QMessageBox.information(self.iface.mainWindow(), "Info",
                    "There was no modification to commit")
Ejemplo n.º 4
0
    def update(self):
        """merge modifiactions since last update into working copy"""
        print "update"
        if self.unresolved_conflicts():
            return
        layer = QgsMapLayerRegistry.instance().mapLayer(
                self.current_layers[0] )
        uri = QgsDataSourceURI(layer.source())

        late_by = 0

        if layer.providerType() == "spatialite":
            late_by = versioning_base.late(
                    uri.database(), self.pg_conn_info() )
        else: # postgres
            late_by = versioning_base.pg_late(
                    self.pg_conn_info(), uri.schema() )
        if late_by:
            if layer.providerType() == "spatialite":
                versioning_base.update( uri.database(), self.pg_conn_info() )
                rev = versioning_base.revision( uri.database() )
            else: # postgres
                versioning_base.pg_update( uri.connectionInfo(), uri.schema() )
                rev = versioning_base.pg_revision(
                        uri.connectionInfo(), uri.schema() )

            # Force refresh of map
            if self.iface.mapCanvas().isCachingEnabled():
                self.iface.mapCanvas().clearCache()
                self.iface.mapCanvas().refresh()
            else:
                self.iface.mapCanvas().refresh()

            # Force refresh of rev number in menu text
            if layer.providerType() == "spatialite":
                self.info.setText( uri.database().split("/")[-1] +' <b>working rev</b>='+str(rev))
            else:
                self.info.setText( uri.database() +' <b>working rev</b>='+str(rev))

            if not self.unresolved_conflicts():
                QMessageBox.warning( self.iface.mainWindow(), "Warning",
                "Working copy was late by "+str(late_by)+" revision(s).\n"
                "Now up to date with remote revision "+str(rev-1)+".")
        else:
            if layer.providerType() == "spatialite":
                rev = versioning_base.revision( uri.database() )
            else: # postgres
                rev = versioning_base.pg_revision(
                        uri.connectionInfo(), uri.schema() )
            QMessageBox.information( self.iface.mainWindow(), "Info","Working "
            "copy already up to date with remote revision "+str(rev-1)+".")
Ejemplo n.º 5
0
    def commit(self):
        """merge modifications into database"""
        print "commit"
        if self.unresolved_conflicts():
            return

        layer = QgsMapLayerRegistry.instance().mapLayer(
                self.current_layers[0] )
        uri = QgsDataSourceURI(layer.source())

        late_by = 0
        if layer.providerType() == "spatialite":
            late_by = versioning_base.late(
                    uri.database(), self.pg_conn_info() )
        else:#postgres
            late_by = versioning_base.pg_late(
                    self.pg_conn_info(), uri.schema() )

        if late_by:
            QMessageBox.warning(self.iface.mainWindow(), "Warning",
                    "This working copy is not up to date (late by "
                    +str(late_by)+" commit(s)).\n\n"
                    "Please update before committing your modifications")
            print "aborted"
            return

        # Make sure the combobox is visible; could be made invisible by a
        # previous call to branch
        self.q_commit_msg_dlg.pg_users_combobox.setVisible(True)
        self.q_commit_msg_dlg.pg_username_label.setVisible(True)
        # Populate combobox with list of pg usernames
        nb_items_in_list = self.q_commit_msg_dlg.pg_users_combobox.count()
        if not(nb_items_in_list) :
            self.get_pg_users_list()
        # Better if we could have a QgsDataSourceURI.username() but no such
        # thing in spatialite.  Next block is for the case the username cannot
        # be found in the connection info string (mainly for plugin tests)
        try:
            pg_username = self.pg_conn_info().split(' ')[3].replace("'","").split('=')[1]
            current_user_index = self.q_commit_msg_dlg.pg_users_combobox.findText(pg_username)
            # sets the current pg_user in the combobox to come
            current_user_combobox_item = self.q_commit_msg_dlg.pg_users_combobox.setCurrentIndex(current_user_index)
        except (IndexError):
            pg_username = ''

        # time to get the commit message
        if not self.q_commit_msg_dlg.exec_():
            return
        commit_msg = self.q_commit_msg_dlg.commitMessage.document().toPlainText()
        commit_pg_user = self.q_commit_msg_dlg.pg_users_combobox.itemText(self.q_commit_msg_dlg.pg_users_combobox.currentIndex())

        if not commit_msg:
            QMessageBox.warning(self.iface.mainWindow(), "Warning",
                    "No commit message, aborting commit")
            print "aborted"
            return

        nb_of_updated_layer = 0
        rev = 0
        if layer.providerType() == "spatialite":
            nb_of_updated_layer = versioning_base.commit( uri.database(),
                    commit_msg, self.pg_conn_info(),commit_pg_user )
            rev = versioning_base.revision(uri.database())
        else: # postgres
            nb_of_updated_layer = versioning_base.pg_commit(
                    uri.connectionInfo(), uri.schema(), commit_msg )
            rev = versioning_base.pg_revision(
                    uri.connectionInfo(), uri.schema())

        if nb_of_updated_layer:
            #self.iface.messageBar().pushMessage("Info",
            #"You have successfully committed revision "+str( rev ), duration=10)
            QMessageBox.information(self.iface.mainWindow(), "Info",
            "You have successfully committed remote revision "+str( rev-1 ) )

            # Force refresh of rev number in menu text
            if layer.providerType() == "spatialite":
                self.info.setText( uri.database().split("/")[-1] +' <b>working rev</b>='+str(rev))
            else:
                self.info.setText( uri.database() +' <b>working rev</b>='+str(rev))
        else:
            #self.iface.messageBar().pushMessage("Info",
            #"There was no modification to commit", duration=10)
            QMessageBox.information(self.iface.mainWindow(), "Info",
            "There was no modification to commit")
Ejemplo n.º 6
0
    def commit(self):
        """merge modifications into database"""
        print "commit"
        if self.unresolved_conflicts():
            return

        layer = QgsMapLayerRegistry.instance().mapLayer(self.current_layers[0])
        uri = QgsDataSourceURI(layer.source())

        late_by = 0
        if layer.providerType() == "spatialite":
            late_by = versioning_base.late(uri.database(), self.pg_conn_info())
        else:  #postgres
            late_by = versioning_base.pg_late(self.pg_conn_info(),
                                              uri.schema())

        if late_by:
            QMessageBox.warning(
                self.iface.mainWindow(), "Warning",
                "This working copy is not up to date (late by " +
                str(late_by) + " commit(s)).\n\n"
                "Please update before committing your modifications")
            print "aborted"
            return

        # Make sure the combobox is visible; could be made invisible by a
        # previous call to branch
        self.q_commit_msg_dlg.pg_users_combobox.setVisible(True)
        self.q_commit_msg_dlg.pg_username_label.setVisible(True)
        # Populate combobox with list of pg usernames
        nb_items_in_list = self.q_commit_msg_dlg.pg_users_combobox.count()
        if not (nb_items_in_list):
            self.get_pg_users_list()
        # Better if we could have a QgsDataSourceURI.username() but no such
        # thing in spatialite.  Next block is for the case the username cannot
        # be found in the connection info string (mainly for plugin tests)
        try:
            pg_username = self.pg_conn_info().split(' ')[3].replace(
                "'", "").split('=')[1]
            current_user_index = self.q_commit_msg_dlg.pg_users_combobox.findText(
                pg_username)
            # sets the current pg_user in the combobox to come
            current_user_combobox_item = self.q_commit_msg_dlg.pg_users_combobox.setCurrentIndex(
                current_user_index)
        except (IndexError):
            pg_username = ''

        # time to get the commit message
        if not self.q_commit_msg_dlg.exec_():
            return
        commit_msg = self.q_commit_msg_dlg.commitMessage.document(
        ).toPlainText()
        commit_pg_user = self.q_commit_msg_dlg.pg_users_combobox.itemText(
            self.q_commit_msg_dlg.pg_users_combobox.currentIndex())

        if not commit_msg:
            QMessageBox.warning(self.iface.mainWindow(), "Warning",
                                "No commit message, aborting commit")
            print "aborted"
            return

        nb_of_updated_layer = 0
        rev = 0
        if layer.providerType() == "spatialite":
            nb_of_updated_layer = versioning_base.commit(
                uri.database(), commit_msg, self.pg_conn_info(),
                commit_pg_user)
            rev = versioning_base.revision(uri.database())
        else:  # postgres
            nb_of_updated_layer = versioning_base.pg_commit(
                uri.connectionInfo(), uri.schema(), commit_msg)
            rev = versioning_base.pg_revision(uri.connectionInfo(),
                                              uri.schema())

        if nb_of_updated_layer:
            #self.iface.messageBar().pushMessage("Info",
            #"You have successfully committed revision "+str( rev ), duration=10)
            QMessageBox.information(
                self.iface.mainWindow(), "Info",
                "You have successfully committed remote revision " +
                str(rev - 1))

            # Force refresh of rev number in menu text
            if layer.providerType() == "spatialite":
                self.info.setText(uri.database().split("/")[-1] +
                                  ' <b>working rev</b>=' + str(rev))
            else:
                self.info.setText(uri.database() + ' <b>working rev</b>=' +
                                  str(rev))
        else:
            #self.iface.messageBar().pushMessage("Info",
            #"There was no modification to commit", duration=10)
            QMessageBox.information(self.iface.mainWindow(), "Info",
                                    "There was no modification to commit")