def addInfoActions(layer):
    commitId = getCommitId(layer)
    tracking = getTrackingInfo(layer)
    repo = Repository(tracking.repoUrl)
    _infoActions[layer.id()] = []
    try:
        commit = Commit.fromref(repo, commitId)
        messageAction = QAction(
            "Message: '%s'" % commit.message.splitlines()[0],
            config.iface.legendInterface())
        f = messageAction.font()
        f.setBold(True)
        messageAction.setFont(f)
        config.iface.legendInterface().addLegendLayerAction(
            messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(
            messageAction, layer)
        _infoActions[layer.id()].append(messageAction)
    except Exception, e:
        QgsMessageLog.logMessage(
            "Cannot connect to server when creating GeoGig layer context:\n %s"
            % str(e),
            level=QgsMessageLog.WARNING)
        messageAction = QAction("Error: Cannot connect with repository",
                                config.iface.legendInterface())
        f = messageAction.font()
        f.setBold(True)
        messageAction.setFont(f)
        config.iface.legendInterface().addLegendLayerAction(
            messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(
            messageAction, layer)
        _infoActions[layer.id()].append(messageAction)
        return False
Exemple #2
0
 def testLayerCommitId(self):
     repo = _createSimpleTestRepo(True)
     log = repo.log()
     filename = tempFilename("gpkg")
     repo.checkoutlayer(filename, "points", ref = log[1].commitid)
     layer = loadLayerNoCrsDialog(filename, "points", "ogr")
     self.assertTrue(log[1].commitid, getCommitId(layer))
def revertLocalChanges(layer):
    if hasLocalChanges(layer):
        tracking = getTrackingInfo(layer)
        repo = Repository(tracking.repoUrl)
        commitid = getCommitId(layer)
        repo.checkoutlayer(tracking.geopkg, tracking.layername, None, commitid)
        config.iface.messageBar().pushMessage("GeoGig", "Local changes have been discarded",
                                                      level=QgsMessageBar.INFO,
                                                      duration=5)
        layer.reload()
        layer.triggerRepaint()
    else:
        config.iface.messageBar().pushMessage("GeoGig", "No local changes were found",
                                                      level=QgsMessageBar.INFO,
                                                      duration=5)
Exemple #4
0
 def testChangeVersion(self):
     repo = _createSimpleTestRepo()
     log = repo.log()
     self.assertEqual(3, len(log))
     commitid = log[-1].commitid
     filename = tempFilename("gpkg")
     repo.checkoutlayer(filename, "points", ref = commitid)
     layer = loadLayerNoCrsDialog(filename, "points", "ogr")
     self.assertTrue(layer.isValid())
     features = list(layer.getFeatures())
     self.assertEqual(1, len(features))
     applyLayerChanges(repo, layer, commitid, repo.HEAD)
     layer.reload()
     self.assertTrue(layer.isValid())
     features = list(layer.getFeatures())
     self.assertEqual(2, len(features))
     self.assertEqual(getCommitId(layer), log[0].commitid)
 def testChangeVersion(self):
     repo = _createSimpleTestRepo()
     log = repo.log()
     self.assertEqual(3, len(log))
     commitid = log[-1].commitid
     filename = tempFilename("gpkg")
     repo.checkoutlayer(filename, "points", ref = commitid)
     layer = loadLayerNoCrsDialog(filename, "points", "ogr")
     self.assertTrue(layer.isValid())
     features = list(layer.getFeatures())
     self.assertEqual(1, len(features))
     applyLayerChanges(repo, layer, commitid, repo.HEAD)
     layer.reload()
     self.assertTrue(layer.isValid())
     features = list(layer.getFeatures())
     self.assertEqual(2, len(features))
     self.assertEqual(getCommitId(layer), log[0].commitid)
def revertLocalChanges(layer):
    if hasLocalChanges(layer):
        tracking = getTrackingInfo(layer)
        repo = Repository(tracking.repoUrl)
        commitid = getCommitId(layer)
        repo.checkoutlayer(tracking.geopkg, tracking.layername, None, commitid)
        config.iface.messageBar().pushMessage(
            "GeoGig",
            "Local changes have been discarded",
            level=QgsMessageBar.INFO,
            duration=5)
        layer.reload()
        layer.triggerRepaint()
    else:
        config.iface.messageBar().pushMessage("GeoGig",
                                              "No local changes were found",
                                              level=QgsMessageBar.INFO,
                                              duration=5)
def revertChange(layer):
    tracking = getTrackingInfo(layer)
    repo = Repository(tracking.repoUrl)
    currentCommitId = getCommitId(layer)
    filename, layername = namesFromLayer(layer)
    dlg = CommitSelectDialog(repo, currentCommitId, layername)
    dlg.exec_()
    if dlg.ref is not None:
        #TODO check that selected commit is in history line
        applyLayerChanges(repo, layer, dlg.ref.commitid,
                          dlg.ref.parent.commitid, False)
        layer.reload()
        layer.triggerRepaint()
        config.iface.messageBar().pushMessage(
            "GeoGig",
            "Version changes have been reverted in local layer",
            level=QgsMessageBar.INFO,
            duration=5)
        commitdialog.suggestedMessage = "Reverted changes from version %s [%s] " % (
            dlg.ref.commitid, dlg.ref.message)
def addInfoActions(layer):
    commitId = getCommitId(layer)
    tracking = getTrackingInfo(layer)
    repo = Repository(tracking.repoUrl)
    layer.infoActions = []
    try:
        commit = Commit.fromref(repo, commitId)
        messageAction = QAction(
            "Message: '%s'" % commit.message.splitlines()[0],
            config.iface.legendInterface())
        f = messageAction.font()
        f.setBold(True)
        messageAction.setFont(f)
        config.iface.legendInterface().addLegendLayerAction(
            messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(
            messageAction, layer)
        layer.infoActions.append(messageAction)
    except:
        messageAction = QAction("Error: Cannot connect with repository",
                                config.iface.legendInterface())
        f = messageAction.font()
        f.setBold(True)
        messageAction.setFont(f)
        config.iface.legendInterface().addLegendLayerAction(
            messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(
            messageAction, layer)
        layer.infoActions.append(messageAction)
        return False
    shaAction = QAction("Version ID: %s" % commitId,
                        config.iface.legendInterface())
    f = shaAction.font()
    f.setBold(True)
    shaAction.setFont(f)
    config.iface.legendInterface().addLegendLayerAction(
        shaAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
    config.iface.legendInterface().addLegendLayerActionForLayer(
        shaAction, layer)
    layer.infoActions.append(shaAction)
    return True
def addInfoActions(layer):
    commitId = getCommitId(layer)
    tracking = getTrackingInfo(layer)
    repo = Repository(tracking.repoUrl)
    _infoActions[layer.id()] = []
    try:
        commit = Commit.fromref(repo, commitId)
        messageAction = QAction("Message: '%s'" % commit.message.splitlines()[0], config.iface.legendInterface())
        f = messageAction.font();
        f.setBold(True);
        messageAction.setFont(f);
        config.iface.legendInterface().addLegendLayerAction(messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(messageAction, layer)
        _infoActions[layer.id()].append(messageAction)
    except Exception, e:
        QgsMessageLog.logMessage("Cannot connect to server when creating GeoGig layer context:\n %s" % str(e), level=QgsMessageLog.WARNING)
        messageAction = QAction("Error: Cannot connect with repository", config.iface.legendInterface())
        f = messageAction.font();
        f.setBold(True);
        messageAction.setFont(f);
        config.iface.legendInterface().addLegendLayerAction(messageAction, u"GeoGig", u"id1", QgsMapLayer.VectorLayer, False)
        config.iface.legendInterface().addLegendLayerActionForLayer(messageAction, layer)
        _infoActions[layer.id()].append(messageAction)
        return False