bool VCSManager::showDeleteDialog(const QString &fileName) { IVersionControl *vc = findVersionControlForDirectory(QFileInfo(fileName).absolutePath()); if (!vc || !vc->supportsOperation(IVersionControl::DeleteOperation)) return true; const QString title = QCoreApplication::translate("VCSManager", "Version Control"); const QString msg = QCoreApplication::translate("VCSManager", "Would you like to remove this file from the version control system (%1)?\n" "Note: This might remove the local file.").arg(vc->name()); const QMessageBox::StandardButton button = QMessageBox::question(0, title, msg, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); if (button != QMessageBox::Yes) return true; return vc->vcsDelete(fileName); }
bool FileUtils::renameFile(const QString &orgFilePath, const QString &newFilePath) { if (orgFilePath == newFilePath) return false; QString dir = QFileInfo(orgFilePath).absolutePath(); IVersionControl *vc = VcsManager::findVersionControlForDirectory(dir); bool result = false; if (vc && vc->supportsOperation(IVersionControl::MoveOperation)) result = vc->vcsMove(orgFilePath, newFilePath); if (!result) // The moving via vcs failed or the vcs does not support moving, fall back result = fileSystemRenameFile(orgFilePath, newFilePath); if (result) { // yeah we moved, tell the filemanager about it Core::DocumentManager::renamedFile(orgFilePath, newFilePath); } return result; }
void VcsCommandPage::delayedInitialize() { auto wiz = qobject_cast<JsonWizard *>(wizard()); QTC_ASSERT(wiz, return); const QString vcsId = wiz->expander()->expand(m_vcsId); IVersionControl *vc = VcsManager::versionControl(Id::fromString(vcsId)); if (!vc) { qWarning() << QCoreApplication::translate("VcsBase::VcsCommandPage", "\"%1\" (%2) not found.") .arg(QLatin1String(VCSCOMMAND_VCSID), vcsId); return; } if (!vc->isConfigured()) { qWarning() << QCoreApplication::translate("VcsBase::VcsCommandPage", "Version control \"%1\" is not configured.") .arg(vcsId); return; } if (!vc->supportsOperation(IVersionControl::InitialCheckoutOperation)) { qWarning() << QCoreApplication::translate("VcsBase::VcsCommandPage", "Version control \"%1\" does not support initial checkouts.") .arg(vcsId); return; } const QString repo = wiz->expander()->expand(m_repository); if (repo.isEmpty()) { qWarning() << QCoreApplication::translate("VcsBase::VcsCommandPage", "\"%1\" is empty when trying to run checkout.") .arg(QLatin1String(VCSCOMMAND_REPO)); return; } const QString base = wiz->expander()->expand(m_directory); if (!QDir(base).exists()) { qWarning() << QCoreApplication::translate("VcsBase::VcsCommandPage", "\"%1\" (%2) does not exist.") .arg(QLatin1String(VCSCOMMAND_DIR), base); return; } const QString name = wiz->expander()->expand(m_name); if (name.isEmpty()) { qWarning() << QCoreApplication::translate("VcsBase::VcsCommandPage", "\"%1\" is empty when trying to run checkout.") .arg(QLatin1String(VCSCOMMAND_CHECKOUTNAME)); return; } const QString runMessage = wiz->expander()->expand(m_runMessage); if (!runMessage.isEmpty()) setStartedStatus(runMessage); QStringList extraArgs; foreach (const QString &in, m_arguments) { const QString tmp = wiz->expander()->expand(in); if (tmp.isEmpty()) continue; if (tmp == QStringLiteral("\"\"")) extraArgs << QString(); extraArgs << tmp; } ShellCommand *command = vc->createInitialCheckoutCommand(repo, Utils::FileName::fromString(base), name, extraArgs); foreach (const JobData &job, m_additionalJobs) { QTC_ASSERT(!job.job.isEmpty(), continue); if (!JsonWizard::boolFromVariant(job.condition, wiz->expander())) continue; QString commandString = wiz->expander()->expand(job.job.at(0)); if (commandString.isEmpty()) continue; QStringList args; for (int i = 1; i < job.job.count(); ++i) { const QString tmp = wiz->expander()->expand(job.job.at(i)); if (tmp.isEmpty() && job.skipEmptyArguments) continue; args << tmp; } const QString dir = wiz->expander()->expand(job.workDirectory); const int timeoutS = command->defaultTimeoutS() * job.timeOutFactor; command->addJob(Utils::FileName::fromUserInput(commandString), args, timeoutS, dir); }