def mergeInto(self, mergeInto, branch):
        conflicts = self.repo.merge(branch, mergeInto)
        if conflicts:
            ret = QMessageBox.warning(iface.mainWindow(), "Conflict(s) found while syncing",
                                      "There are conflicts between local and remote changes.\n"
                                      "Do you want to continue and fix them?",
                                      QMessageBox.Yes | QMessageBox.No)
            if ret == QMessageBox.No:
                self.repo.closeTransaction(conflicts[0].transactionId)
                return

            dlg = ConflictDialog(conflicts)
            dlg.exec_()
            solved, resolvedConflicts = dlg.solved, dlg.resolvedConflicts
            if not solved:
                self.repo.closeTransaction(conflicts[0].transactionId)
                return
            for conflict, resolution in zip(conflicts, list(resolvedConflicts.values())):
                if resolution == ConflictDialog.LOCAL:
                    conflict.resolveWithLocalVersion()
                elif resolution == ConflictDialog.REMOTE:
                    conflict.resolveWithRemoteVersion()
                elif resolution == ConflictDialog.DELETE:
                    conflict.resolveDeletingFeature()
                else:
                    conflict.resolveWithNewFeature(resolution)
            user, email = config.getUserInfo()
            if user is None:
                return
            self.repo.commitAndCloseMergeAndTransaction(user, email, "Resolved merge conflicts", conflicts[0].transactionId)


        iface.messageBar().pushMessage("GeoGig", "Branch has been correctly merged",
                                              level=QgsMessageBar.INFO, duration=5)
        repoWatcher.repoChanged.emit(self.repo)
 def linkClicked(self, url):
     if url == "abort":
         self.repo.repo().abort()
         self.updateLabelText()
     elif url == "solve":
         dlg = ConflictDialog(self, self.repo.repo())
         dlg.exec_()
         if dlg.solved:
             self.repo.repo().addandcommit(self.repo.repo().mergemessage())
             self.repoChanged.emit()
             self.updateLabelText()
Beispiel #3
0
    def mergeInto(self, mergeInto, branch):
        conflicts = self.repo.merge(branch, mergeInto)
        if conflicts:
            ret = QMessageBox.warning(
                iface.mainWindow(), "Error while syncing",
                "There are conflicts between local and remote changes.\n"
                "Do you want to continue and fix them?",
                QMessageBox.Yes | QMessageBox.No)
            if ret == QMessageBox.No:
                self.repo.closeTransaction(conflicts[0].transactionId)
                return

            dlg = ConflictDialog(conflicts)
            dlg.exec_()
            solved, resolvedConflicts = dlg.solved, dlg.resolvedConflicts
            if not solved:
                self.repo.closeTransaction(conflicts[0].transactionId)
                return
            for conflict, resolution in zip(conflicts,
                                            list(resolvedConflicts.values())):
                if resolution == ConflictDialog.LOCAL:
                    conflict.resolveWithLocalVersion()
                elif resolution == ConflictDialog.REMOTE:
                    conflict.resolveWithRemoteVersion()
                elif resolution == ConflictDialog.DELETE:
                    conflict.resolveDeletingFeature()
                else:
                    conflict.resolveWithNewFeature(resolution)
            user, email = config.getUserInfo()
            if user is None:
                return
            self.repo.commitAndCloseMergeAndTransaction(
                user, email, "Resolved merge conflicts",
                conflicts[0].transactionId)

        iface.messageBar().pushMessage("GeoGig",
                                       "Branch has been correctly merged",
                                       level=QgsMessageBar.INFO,
                                       duration=5)
        repoWatcher.repoChanged.emit(self.repo)
    def pull(self):
        dlg = RemoteRefDialog(self.repo)
        dlg.exec_()
        if dlg.remote is not None:
            conflicts = execute(lambda: self.repo.pull(dlg.remote, dlg.branch))
            if conflicts:
                ret = QMessageBox.warning(
                    iface.mainWindow(), "Conflict(s) found while syncing",
                    "There are conflicts between local repository and connection.\n"
                    "Do you want to continue and fix them?",
                    QMessageBox.Yes | QMessageBox.No)
                if ret == QMessageBox.No:
                    self.repo.closeTransaction(conflicts[0].transactionId)
                    return

                dlg = ConflictDialog(conflicts)
                dlg.exec_()
                solved, resolvedConflicts = dlg.solved, dlg.resolvedConflicts
                if not solved:
                    self.repo.closeTransaction(conflicts[0].transactionId)
                    return
                for conflict, resolution in zip(
                        conflicts, list(resolvedConflicts.values())):
                    if resolution == ConflictDialog.LOCAL:
                        conflict.resolveWithLocalVersion()
                    elif resolution == ConflictDialog.REMOTE:
                        conflict.resolveWithRemoteVersion()
                    elif resolution == ConflictDialog.DELETE:
                        conflict.resolveDeletingFeature()
                    else:
                        conflict.resolveWithNewFeature(resolution)
                user, email = config.getUserInfo()
                if user is None:
                    return
                self.repo.commitAndCloseMergeAndTransaction(
                    user, email, "Resolved merge conflicts",
                    conflicts[0].transactionId)
                config.iface.messageBar().pushMessage(
                    "Changes have been correctly pulled from the connection",
                    level=QgsMessageBar.INFO,
                    duration=5)
                repoWatcher.repoChanged.emit(self.repo)
            else:
                config.iface.messageBar().pushMessage(
                    "Changes have been correctly pulled from the connection",
                    level=QgsMessageBar.INFO,
                    duration=5)
                repoWatcher.repoChanged.emit(self.repo)
Beispiel #5
0
def solveConflicts(conflicts):
    dlg = ConflictDialog(conflicts)
    dlg.exec_()
    return dlg.solved, dlg.resolvedConflicts