void HgBackoutDialog::done(int r) { if (r == QDialog::Accepted) { HgWrapper *hgw = HgWrapper::instance(); QStringList args; args << QLatin1String("--rev"); args << m_baseRevision->text(); if (!m_parentRevision->text().isEmpty()) { args << QLatin1String("--parent"); args << m_parentRevision->text(); } if (m_optMerge->checkState() == Qt::Checked) { args << QLatin1String("--merge"); } if (hgw->executeCommandTillFinished(QLatin1String("backout"), args)) { KMessageBox::information(this, hgw->readAllStandardOutput()); QDialog::done(r); } else { KMessageBox::error(this, hgw->readAllStandardError()); } } else { QDialog::done(r); } }
void HgUpdateDialog::slotUpdateDialog(int index) { HgWrapper *hgWrapper = HgWrapper::instance(); m_selectFinal->clear(); if (index == 0) { m_updateTo = ToBranch; m_selectFinal->setEditable(false); m_selectFinal->addItems(hgWrapper->getBranches()); } else if (index == 1) { m_updateTo = ToTag; m_selectFinal->setEditable(false); m_selectFinal->addItems(hgWrapper->getTags()); } else if (index == 2) { m_updateTo = ToRevision; m_selectFinal->setEditable(true); } m_selectFinal->setFocus(); /// get parents of current working directory /// more precise informtaion using 'hg summary' /// but no proper way to retrieve needed data QString output; QStringList args; args << QLatin1String("--template"); args << QLatin1String("{rev}:{node|short} ({branch})\n"); hgWrapper->executeCommand(QLatin1String("parents"), args, output); output.replace(QLatin1String("\n"), QLatin1String("<br/>")); if (output.contains(QLatin1String("()"))) { output.replace(QLatin1String("()"), QLatin1String("(default)")); } m_currentInfo->setText(output); }
void HgBundleDialog::createBundle(const QString &fileName) { HgWrapper *hgw = HgWrapper::instance(); QStringList args; if (m_allChangesets->checkState() == Qt::Checked) { args << QLatin1String("--all"); } else { if (m_baseRevision->text().trimmed().length() > 0) { args << QLatin1String("--base"); args << m_baseRevision->text().trimmed(); } } if (m_optForce->checkState() == Qt::Checked) { args << QLatin1String("--force"); } if (m_optInsecure->checkState() == Qt::Checked) { args << QLatin1String("--insecure"); } args << fileName; args << m_pathSelect->remote(); hgw->executeCommand(QLatin1String("bundle"), args); }
void HgUpdateDialog::done(int r) { if (r == KDialog::Accepted) { QStringList args; // Should we discard uncommitted changes if (m_discardChanges->checkState() == Qt::Checked) { args << "-C"; } else { args << "-c"; } if (m_updateTo == ToRevision) { args << "-r"; } // update to args << m_selectFinal->currentText(); // execute mercurial command HgWrapper *hgw = HgWrapper::instance(); if (hgw->executeCommandTillFinished(QLatin1String("update"), args)) { KDialog::done(r); } else { KMessageBox::error(this, i18n("Some error occurred! " "\nMaybe there are uncommitted changes.")); } } else { KDialog::done(r); } }
void HgCommitDialog::slotItemSelectionChanged(const char status, const QString &fileName) { m_fileDiffDoc->setReadWrite(true); m_fileDiffDoc->setModified(false); m_fileDiffDoc->closeUrl(true); if (status != '?') { QStringList arguments; QString diffOut; HgWrapper *hgWrapper = HgWrapper::instance(); arguments << fileName; hgWrapper->executeCommand(QLatin1String("diff"), arguments, diffOut); kDebug() << diffOut; m_fileDiffDoc->setText(diffOut); m_fileDiffDoc->setHighlightingMode("diff"); } else { KUrl url(HgWrapper::instance()->getBaseDir()); url.addPath(fileName); m_fileDiffDoc->openUrl(url); } m_fileDiffDoc->setReadWrite(false); m_fileDiffView->setCursorPosition( KTextEditor::Cursor(0, 0) ); }
void HgCommitDialog::done(int r) { if (r == KDialog::Accepted) { QStringList files; if (m_statusList->getSelectionForCommit(files)) { HgWrapper *hgWrapper = HgWrapper::instance(); if (m_branchAction == NewBranch) { if (!hgWrapper->createBranch(m_newBranchName)) { KMessageBox::error(this, i18n("Could not create branch! Aborting commit!")); return; } } bool success = hgWrapper->commit(m_commitMessage->toPlainText(), files, m_branchAction==CloseBranch); if (success) { KDialog::done(r); } else { KMessageBox::error(this, i18n("Commit unsuccessful!")); } } else { KMessageBox::error(this, i18n("No files for commit!")); } } else { KDialog::done(r); } }
QString HgCommitDialog::getParentForLabel() { HgWrapper *hgWrapper = HgWrapper::instance(); QString line("<b>parents:</b> "); line += hgWrapper->getParentsOfHead(); return line; }
void HgMergeDialog::done(int r) { if (r == KDialog::Accepted) { HgWrapper *hgw = HgWrapper::instance(); QListWidgetItem *currentItem = m_commitInfoWidget->currentItem(); if (currentItem == 0) { KMessageBox::error(this, i18nc("@message", "No head selected for merge!")); return; } QString changeset = m_commitInfoWidget->selectedChangeset(); QStringList args; args << QLatin1String("-r"); args << changeset; if (hgw->executeCommandTillFinished(QLatin1String("merge"), args)) { KMessageBox::information(this, hgw->readAllStandardOutput()); KDialog::done(r); } else { KMessageBox::error(this, hgw->readAllStandardError()); return; } } else { KDialog::done(r); } }
void HgRenameDialog::done(int r) { if (r == KDialog::Accepted) { HgWrapper *hgi = HgWrapper::instance(); hgi->renameFile(source(), destination()); } KDialog::done(r); }
void HgIgnoreWidget::setupUntrackedList() { HgWrapper *hgw = HgWrapper::instance(); QStringList args; args << QLatin1String("--unknown"); QString output; hgw->executeCommand(QLatin1String("status"), args, output); QStringList result = output.split('\n', QString::SkipEmptyParts); foreach (QString file, result) { m_untrackedList->addItem(file.mid(2)); }
void HgCommitDialog::slotInitDiffOutput() { m_fileDiffDoc->setReadWrite(true); m_fileDiffDoc->setModified(false); m_fileDiffDoc->closeUrl(true); QString diffOut; HgWrapper *hgWrapper = HgWrapper::instance(); hgWrapper->executeCommand(QLatin1String("diff"), QStringList(), diffOut); m_fileDiffDoc->setHighlightingMode("diff"); m_fileDiffDoc->setText(diffOut); m_fileDiffView->setCursorPosition( KTextEditor::Cursor(0, 0) ); m_fileDiffDoc->setReadWrite(false); }
void HgMergeDialog::updateInitialDialog() { HgWrapper *hgWrapper = HgWrapper::instance(); // update label - current branch QString line("<b>parents:</b> "); line += hgWrapper->getParentsOfHead(); m_currentChangeset->setText(line); // update heads list QProcess process; process.setWorkingDirectory(hgWrapper->getBaseDir()); QStringList args; args << QLatin1String("heads"); args << QLatin1String("--template"); args << QLatin1String("{rev}\n{node|short}\n{branch}\n" "{author}\n{desc|firstline}\n"); process.start(QLatin1String("hg"), args); m_commitInfoWidget->clear(); const int FINAL = 5; char buffer[FINAL][1024]; int count = 0; while (process.waitForReadyRead()) { while (process.readLine(buffer[count], sizeof(buffer[count])) > 0) { if (count == FINAL - 1) { QString rev = QTextCodec::codecForLocale()->toUnicode(buffer[0]).trimmed(); QString changeset = QTextCodec::codecForLocale()->toUnicode(buffer[1]).trimmed(); QString branch = QTextCodec::codecForLocale()->toUnicode(buffer[2]).trimmed(); QString author = QTextCodec::codecForLocale()->toUnicode(buffer[3]).trimmed(); QString log = QTextCodec::codecForLocale()->toUnicode(buffer[4]).trimmed(); QListWidgetItem *item = new QListWidgetItem; item->setData(Qt::DisplayRole, changeset); item->setData(Qt::UserRole + 1, rev); item->setData(Qt::UserRole + 2, branch); item->setData(Qt::UserRole + 3, author); item->setData(Qt::UserRole + 4, log); m_commitInfoWidget->addItem(item); } count = (count + 1)%FINAL; } } }
void HgCommitDialog::createCopyMessageMenu() { QActionGroup *actionGroup = new QActionGroup(this); connect(actionGroup, SIGNAL(triggered(QAction *)), this, SLOT(slotInsertCopyMessage(QAction *))); QStringList args; args << QLatin1String("--limit"); args << QLatin1String("5"); args << QLatin1String("--template"); args << QLatin1String("{desc|short}\n"); HgWrapper *hgw = HgWrapper::instance(); QString output; hgw->executeCommand(QLatin1String("log"), args, output); QStringList messages = output.split('\n', QString::SkipEmptyParts); foreach (QString msg, messages) { QAction *action = m_copyMessageMenu->addAction(msg); actionGroup->addAction(action); }
void HgImportDialog::done(int r) { if (r == QDialog::Accepted) { QStringList args; if (m_optForce->checkState() == Qt::Checked) { args << QLatin1String("--force"); } if (m_optBypass->checkState() == Qt::Checked) { args << QLatin1String("--bypass"); } if (m_optNoCommit->checkState() == Qt::Checked) { args << QLatin1String("--no-commit"); } if (m_optExact->checkState() == Qt::Checked) { args << QLatin1String("--exact"); } int countRows = m_patchList->count(); for (int i=0; i<countRows; i++) { QListWidgetItem *item = m_patchList->item(i); args << item->data(Qt::UserRole + 5).toString(); } HgWrapper *hgw = HgWrapper::instance(); if (hgw->executeCommandTillFinished(QLatin1String("import"), args)) { QDialog::done(r); } else { KMessageBox::error(this, hgw->readAllStandardError()); } } else { QDialog::done(r); } }
void HgStatusList::reloadStatusTable() { m_statusTable->clearContents(); m_statusTable->resizeRowsToContents(); m_statusTable->resizeColumnsToContents(); m_statusTable->horizontalHeader()->setStretchLastSection(true); HgWrapper *hgWrapper = HgWrapper::instance(); QHash<QString, KVersionControlPlugin2::ItemVersion> hgVsState; hgWrapper->getItemVersions(hgVsState); QMutableHashIterator<QString, KVersionControlPlugin2::ItemVersion> it(hgVsState); int rowCount = 0; while (it.hasNext()) { it.next(); KVersionControlPlugin2::ItemVersion currentStatus = it.value(); // Get path relative to root directory of repository // FIXME: preferred method, but not working :| bad hack below // QString currentFile // = KUrl::relativeUrl(hgWrapper->getBaseDir(), it.key()); QString currentFile = it.key().mid(hgWrapper->getBaseDir().length()+1); QString currentStatusString; //one character status indicator // Temporarily ignoring // TODO: Ask to add file if this is checked by user if (currentStatus == KVersionControlPlugin2::UnversionedVersion || currentStatus == KVersionControlPlugin2::IgnoredVersion) { continue; } QTableWidgetItem *check = new QTableWidgetItem; QTableWidgetItem *status = new QTableWidgetItem; QTableWidgetItem *fileName = new QTableWidgetItem; switch (currentStatus) { case KVersionControlPlugin2::AddedVersion: status->setForeground(Qt::darkCyan); fileName->setForeground(Qt::darkCyan); check->setCheckState(Qt::Checked); currentStatusString = QLatin1String("A"); break; case KVersionControlPlugin2::LocallyModifiedVersion: status->setForeground(Qt::blue); fileName->setForeground(Qt::blue); check->setCheckState(Qt::Checked); currentStatusString = QLatin1String("M"); break; case KVersionControlPlugin2::RemovedVersion: status->setForeground(Qt::red); fileName->setForeground(Qt::red); check->setCheckState(Qt::Checked); currentStatusString = QLatin1String("R"); break; case KVersionControlPlugin2::UnversionedVersion: status->setForeground(Qt::darkMagenta); fileName->setForeground(Qt::darkMagenta); currentStatusString = QLatin1String("?"); break; case KVersionControlPlugin2::IgnoredVersion: status->setForeground(Qt::black); fileName->setForeground(Qt::black); currentStatusString = QLatin1String("I"); break; case KVersionControlPlugin2::MissingVersion: status->setForeground(Qt::black); fileName->setForeground(Qt::black); currentStatusString = QLatin1String("!"); break; default: break; } status->setText(QString(currentStatusString)); fileName->setText(currentFile); m_statusTable->insertRow(rowCount); check->setCheckState(Qt::Checked); //Change. except untracked, ignored m_statusTable->setItem(rowCount, 0, check); m_statusTable->setItem(rowCount, 1, status); m_statusTable->setItem(rowCount, 2, fileName); ++rowCount; } }