Mercurial > hg > easyhg
changeset 120:c92f5859c707
* Add incremental log (though not incremental relayout)
author | Chris Cannam |
---|---|
date | Mon, 29 Nov 2010 11:01:19 +0000 |
parents | 005a54380502 |
children | 6ce2ceb2c3a5 |
files | hgrunner.cpp hgtabwidget.cpp hgtabwidget.h historywidget.cpp historywidget.h mainwindow.cpp mainwindow.h |
diffstat | 7 files changed, 128 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/hgrunner.cpp Sun Nov 28 21:52:00 2010 +0000 +++ b/hgrunner.cpp Mon Nov 29 11:01:19 2010 +0000 @@ -50,7 +50,10 @@ HgRunner::~HgRunner() { closeTerminal(); - if (m_proc) delete m_proc; + if (m_proc) { + m_proc->kill(); + delete m_proc; + } } void HgRunner::requestAction(HgAction action)
--- a/hgtabwidget.cpp Sun Nov 28 21:52:00 2010 +0000 +++ b/hgtabwidget.cpp Mon Nov 29 11:01:19 2010 +0000 @@ -127,9 +127,14 @@ m_fileStatusWidget->setFileStates(m_fileStates); } -void HgTabWidget::updateLocalRepoHgLogList(QString hgLogList) +void HgTabWidget::setNewLog(QString hgLogList) { - m_historyWidget->parseLog(hgLogList); + m_historyWidget->parseNewLog(hgLogList); +} + +void HgTabWidget::addIncrementalLog(QString hgLogList) +{ + m_historyWidget->parseIncrementalLog(hgLogList); } void HgTabWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath)
--- a/hgtabwidget.h Sun Nov 28 21:52:00 2010 +0000 +++ b/hgtabwidget.h Mon Nov 29 11:01:19 2010 +0000 @@ -41,7 +41,10 @@ HgTabWidget(QWidget *parent, QString remoteRepo, QString workFolderPath); void updateWorkFolderFileList(QString fileList); - void updateLocalRepoHgLogList(QString hgLogList); + + void setNewLog(QString hgLogList); + void addIncrementalLog(QString hgLogList); + void setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath); void setState(QString state);
--- a/historywidget.cpp Sun Nov 28 21:52:00 2010 +0000 +++ b/historywidget.cpp Mon Nov 29 11:01:19 2010 +0000 @@ -52,20 +52,42 @@ m_changesets.clear(); } -void HistoryWidget::parseLog(QString log) +void HistoryWidget::parseNewLog(QString log) +{ + DEBUG << "HistoryWidget::parseNewLog: log has " << log.length() << " chars" << endl; + Changesets csets = parseChangeSets(log); + DEBUG << "HistoryWidget::parseNewLog: log has " << csets.size() << " changesets" << endl; + clearChangesets(); + m_changesets = csets; + layoutAll(); +} + +void HistoryWidget::parseIncrementalLog(QString log) +{ + DEBUG << "HistoryWidget::parseIncrementalLog: log has " << log.length() << " chars" << endl; + Changesets csets = parseChangeSets(log); + DEBUG << "HistoryWidget::parseIncrementalLog: log has " << csets.size() << " changesets" << endl; + if (!csets.empty()) { + m_changesets << csets; + layoutAll(); + } +} + +void HistoryWidget::layoutAll() { ChangesetScene *scene = new ChangesetScene(); - Changesets csets = parseChangeSets(log); ChangesetItem *tipItem = 0; - if (!csets.empty()) { + if (!m_changesets.empty()) { Grapher g(scene); try { - g.layout(csets); + g.layout(m_changesets); } catch (std::string s) { std::cerr << "Internal error: Layout failed: " << s << std::endl; } - tipItem = g.getItemFor(csets[0]); + tipItem = g.getItemFor(m_changesets[0]); + DEBUG << "tipItem is " << tipItem << " for tip changeset " + << m_changesets[0]->id() << endl; } QGraphicsScene *oldScene = m_panned->scene(); @@ -73,10 +95,6 @@ m_panner->setScene(scene); if (oldScene) delete oldScene; - clearChangesets(); - - m_changesets = csets; - if (tipItem) tipItem->ensureVisible(); }
--- a/historywidget.h Sun Nov 28 21:52:00 2010 +0000 +++ b/historywidget.h Mon Nov 29 11:01:19 2010 +0000 @@ -33,7 +33,8 @@ HistoryWidget(); virtual ~HistoryWidget(); - void parseLog(QString log); + void parseNewLog(QString log); + void parseIncrementalLog(QString log); private: Changesets m_changesets; @@ -42,6 +43,7 @@ Panner *m_panner; void clearChangesets(); + void layoutAll(); Changesets parseChangeSets(QString); };
--- a/mainwindow.cpp Sun Nov 28 21:52:00 2010 +0000 +++ b/mainwindow.cpp Mon Nov 29 11:01:19 2010 +0000 @@ -64,7 +64,6 @@ readSettings(); -// tabPage = 0; justMerged = false; hgTabs = new HgTabWidget((QWidget *) this, remoteRepoPath, workFolderPath); setCentralWidget(hgTabs); @@ -74,6 +73,7 @@ setUnifiedTitleAndToolBarOnMac(true); connectActions(); + clearState(); enableDisableActions(); if (firstStart) { @@ -145,6 +145,12 @@ hgTabs->clearSelections(); } +void MainWindow::hgRefresh() +{ + clearState(); + hgQueryPaths(); +} + void MainWindow::hgStat() { QStringList params; @@ -176,8 +182,6 @@ void MainWindow::hgLog() { -//!!! This needs to be incremental, except when we pull or set new repo. - // Be sure to use ACT_LOG_INCREMENTAL for incremental logs QStringList params; params << "log"; params << "--template"; @@ -186,6 +190,21 @@ runner->requestAction(HgAction(ACT_LOG, workFolderPath, params)); } +void MainWindow::hgLogIncremental() +{ + QStringList params; + params << "log"; + + foreach (Changeset *head, currentHeads) { + int n = head->number(); + params << "--prune" << QString("%1").arg(n); + } + + params << "--template"; + params << "id: {rev}:{node|short}\\nauthor: {author}\\nbranch: {branches}\\ntag: {tag}\\ndatetime: {date|isodate}\\ntimestamp: {date|hgdate}\\nage: {date|age}\\nparents: {parents}\\ncomment: {desc|json}\\n\\n"; + + runner->requestAction(HgAction(ACT_LOG_INCREMENTAL, workFolderPath, params)); +} void MainWindow::hgQueryParents() { @@ -613,6 +632,15 @@ return ret; } +void MainWindow::clearState() +{ + foreach (Changeset *cs, currentParents) delete cs; + currentParents.clear(); + foreach (Changeset *cs, currentHeads) delete cs; + currentHeads.clear(); + currentBranch = ""; + needNewLog = true; +} void MainWindow::hgServe() { @@ -680,6 +708,7 @@ if (result) { enableDisableActions(); + clearState(); hgQueryPaths(); done = true; } @@ -998,16 +1027,32 @@ void MainWindow::fsDirectoryChanged(QString) { - //!!! should just queue one of these! hgStat(); } void MainWindow::fsFileChanged(QString) { - //!!! should just queue one of these! hgStat(); } +void MainWindow::showIncoming(QString output) +{ + runner->hide(); + QMessageBox::information(this, "Incoming", output); +} + +void MainWindow::showPushResult(QString output) +{ + runner->hide(); + QMessageBox::information(this, "Push", output); +} + +void MainWindow::showPullResult(QString output) +{ + runner->hide(); + QMessageBox::information(this, "Pull", output); +} + void MainWindow::commandFailed(HgAction action, QString stderr) { DEBUG << "MainWindow::commandFailed" << endl; @@ -1090,6 +1135,9 @@ break; case ACT_INCOMING: + showIncoming(output); + break; + case ACT_ANNOTATE: case ACT_RESOLVE_LIST: case ACT_RESOLVE_MARK: @@ -1098,13 +1146,12 @@ break; case ACT_PULL: - QMessageBox::information(this, "Pull", output); + showPullResult(output); shouldHgStat = true; break; case ACT_PUSH: - QMessageBox::information(this, "Push", output); - shouldHgStat = true; + showPushResult(output); break; case ACT_INIT: @@ -1124,7 +1171,12 @@ break; case ACT_LOG: - hgTabs -> updateLocalRepoHgLogList(output); + hgTabs->setNewLog(output); + needNewLog = false; + break; + + case ACT_LOG_INCREMENTAL: + hgTabs->addIncrementalLog(output); break; case ACT_QUERY_PARENTS: @@ -1187,7 +1239,11 @@ } else if (action == ACT_QUERY_HEADS) { hgQueryParents(); } else if (action == ACT_QUERY_PARENTS) { - hgLog(); + if (needNewLog) { + hgLog(); + } else { + hgLogIncremental(); + } } else /* Move to commandFailed if ((runningAction == ACT_MERGE) && (exitCode != 0)) @@ -1218,7 +1274,7 @@ connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); - connect(hgStatAct, SIGNAL(triggered()), this, SLOT(hgQueryPaths())); + connect(hgRefreshAct, SIGNAL(triggered()), this, SLOT(hgRefresh())); connect(hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove())); connect(hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd())); connect(hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit())); @@ -1305,7 +1361,7 @@ bool haveDiff = (diffBinaryName != ""); hgInitAct -> setEnabled((localRepoExist == false) && (workFolderExist==true)); - hgStatAct -> setEnabled(localRepoActionsEnabled); + hgRefreshAct -> setEnabled(localRepoActionsEnabled); hgFileDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff); hgFolderDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff); hgRevertAct -> setEnabled(localRepoActionsEnabled); @@ -1413,8 +1469,8 @@ exitAct -> setIconVisibleInMenu(true); //Repository actions - hgStatAct = new QAction(QIcon(":/images/status.png"), tr("Refresh"), this); - hgStatAct->setStatusTip(tr("Refresh (info of) status of workfolder files")); + hgRefreshAct = new QAction(QIcon(":/images/status.png"), tr("Refresh"), this); + hgRefreshAct->setStatusTip(tr("Refresh (info of) status of workfolder files")); hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("Preview"), this); hgIncomingAct -> setStatusTip(tr("View info of changesets incoming to us from remote repository (on pull operation)")); @@ -1527,7 +1583,7 @@ fileToolBar = addToolBar(tr("File")); fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE)); fileToolBar -> addAction(openAct); - fileToolBar -> addAction(hgStatAct); + fileToolBar -> addAction(hgRefreshAct); fileToolBar -> addSeparator(); // fileToolBar -> addAction(hgChgSetDiffAct); fileToolBar -> setMovable(false);
--- a/mainwindow.h Sun Nov 28 21:52:00 2010 +0000 +++ b/mainwindow.h Mon Nov 29 11:01:19 2010 +0000 @@ -49,13 +49,13 @@ QString currentBranch; Changesets currentHeads; Changesets currentParents; + bool needNewLog; protected: void closeEvent(QCloseEvent *event); public slots: - void hgQueryPaths(); - void hgStat(); + void hgRefresh(); void commandCompleted(HgAction action, QString stdout); void commandFailed(HgAction action, QString stdout); void enableDisableActions(); @@ -67,6 +67,8 @@ void startupDialog(); void clearSelections(); + void hgQueryPaths(); + void hgStat(); void hgRemove(); void hgAdd(); void hgCommit(); @@ -98,6 +100,7 @@ void hgQueryHeads(); void hgQueryParents(); void hgLog(); + void hgLogIncremental(); void createActions(); void connectActions(); void createMenus(); @@ -129,6 +132,12 @@ bool askToOpenParentRepo(QString, QString); bool askToOpenInsteadOfInit(QString); + void showIncoming(QString); + void showPullResult(QString); + void showPushResult(QString); + + void clearState(); + void updateFileSystemWatcher(); bool firstStart; @@ -148,7 +157,7 @@ QAction *hgIncomingAct; QAction *hgPushAct; QAction *hgPullAct; - QAction *hgStatAct; + QAction *hgRefreshAct; QAction *hgFileDiffAct; QAction *hgFolderDiffAct; QAction *hgChgSetDiffAct;