# HG changeset patch # User Chris Cannam # Date 1320770529 0 # Node ID 000f13faa08940ccfd740045f2eb2711cc4e4c31 # Parent 5c846f3c9244179592fe40ac58e98b1817d31646 Bookmarks are now displayed -- but exactly like tags, so far, there's no differentiation yet diff -r 5c846f3c9244 -r 000f13faa089 src/changesetitem.cpp --- a/src/changesetitem.cpp Thu Oct 20 15:39:46 2011 +0100 +++ b/src/changesetitem.cpp Tue Nov 08 16:42:09 2011 +0000 @@ -407,6 +407,13 @@ } } + if (!m_bookmarks.empty()) { + QString bmText = m_bookmarks.join(" ").trimmed(); + int bw = fm.width(bmText); + paint->fillRect(QRectF(x0 + width - 8 - bw, 1, bw + 4, fh - 1), + QBrush(Qt::yellow)); paint->drawText(x0 + width - 6 - bw, fm.ascent(), bmText); + } + paint->setPen(QPen(branchColour, 2)); paint->setBrush(Qt::NoBrush); paint->drawRoundedRect(r, 7, 7); diff -r 5c846f3c9244 -r 000f13faa089 src/changesetitem.h --- a/src/changesetitem.h Thu Oct 20 15:39:46 2011 +0100 +++ b/src/changesetitem.h Tue Nov 08 16:42:09 2011 +0000 @@ -65,6 +65,8 @@ bool showBranch() const { return m_showBranch; } void setShowBranch(bool s) { m_showBranch = s; } + void setBookmarks(QStringList b) { m_bookmarks = b; } + signals: void detailShown(); void detailHidden(); @@ -110,6 +112,7 @@ bool m_current; bool m_closing; bool m_new; + QStringList m_bookmarks; QMap m_parentDiffActions; QMap m_summaryActions; diff -r 5c846f3c9244 -r 000f13faa089 src/hgaction.h --- a/src/hgaction.h Thu Oct 20 15:39:46 2011 +0100 +++ b/src/hgaction.h Tue Nov 08 16:42:09 2011 +0000 @@ -59,7 +59,8 @@ ACT_NEW_BRANCH, ACT_HG_IGNORE, ACT_COPY_FILE, - ACT_RENAME_FILE + ACT_RENAME_FILE, + ACT_QUERY_BOOKMARKS }; struct HgAction @@ -97,6 +98,7 @@ case ACT_QUERY_HEADS_ACTIVE: case ACT_QUERY_PARENTS: case ACT_LOG_INCREMENTAL: + case ACT_QUERY_BOOKMARKS: return true; default: return false; diff -r 5c846f3c9244 -r 000f13faa089 src/hgtabwidget.cpp --- a/src/hgtabwidget.cpp Thu Oct 20 15:39:46 2011 +0100 +++ b/src/hgtabwidget.cpp Tue Nov 08 16:42:09 2011 +0000 @@ -144,6 +144,11 @@ m_historyWidget->setClosedHeadIds(closed); } +void HgTabWidget::setBookmarks(QHash bmarks) +{ + m_historyWidget->setBookmarks(bmarks); +} + void HgTabWidget::updateFileStates() { m_fileStatusWidget->updateWidgets(); diff -r 5c846f3c9244 -r 000f13faa089 src/hgtabwidget.h --- a/src/hgtabwidget.h Thu Oct 20 15:39:46 2011 +0100 +++ b/src/hgtabwidget.h Tue Nov 08 16:42:09 2011 +0000 @@ -50,6 +50,8 @@ void setCurrent(QStringList ids, QString branch); void setClosedHeadIds(QSet ids); + void setBookmarks(QHash bmarks); + void setHaveMerge(bool); void updateFileStates(); diff -r 5c846f3c9244 -r 000f13faa089 src/historywidget.cpp --- a/src/historywidget.cpp Thu Oct 20 15:39:46 2011 +0100 +++ b/src/historywidget.cpp Tue Nov 08 16:42:09 2011 +0000 @@ -104,6 +104,11 @@ m_refreshNeeded = true; } +void HistoryWidget::setBookmarks(QHash bookmarks) +{ + m_bookmarks = bookmarks; +} + void HistoryWidget::setClosedHeadIds(QSet closed) { if (closed == m_closedIds) return; @@ -285,6 +290,12 @@ DEBUG << "id " << id << " is new" << endl; } + if (m_bookmarks.contains(id)) { + csit->setBookmarks(m_bookmarks[id]); + } else { + csit->setBookmarks(QStringList()); + } + if (csit->isCurrent() != current || csit->isNew() != newid) { csit->setCurrent(current); diff -r 5c846f3c9244 -r 000f13faa089 src/historywidget.h --- a/src/historywidget.h Thu Oct 20 15:39:46 2011 +0100 +++ b/src/historywidget.h Tue Nov 08 16:42:09 2011 +0000 @@ -39,8 +39,8 @@ void setCurrent(QStringList ids, QString branch, bool showUncommitted); void setShowUncommitted(bool showUncommitted); - void setClosedHeadIds(QSet closed); + void setBookmarks(QHash bmarks); void parseNewLog(QString log); void parseIncrementalLog(QString log); @@ -76,6 +76,7 @@ QString m_currentBranch; QSet m_newIds; QSet m_closedIds; + QHash m_bookmarks; bool m_showUncommitted; bool m_refreshNeeded; diff -r 5c846f3c9244 -r 000f13faa089 src/mainwindow.cpp --- a/src/mainwindow.cpp Thu Oct 20 15:39:46 2011 +0100 +++ b/src/mainwindow.cpp Tue Nov 08 16:42:09 2011 +0000 @@ -323,6 +323,13 @@ */ } +void MainWindow::hgQueryBookmarks() +{ + QStringList params; + params << "bookmarks"; + m_runner->requestAction(HgAction(ACT_QUERY_BOOKMARKS, m_workFolderPath, params)); +} + void MainWindow::hgQueryHeadsActive() { QStringList params; @@ -2195,6 +2202,10 @@ // and some return with failure codes when something as basic // as the user closing the window via the wm happens return; + case ACT_QUERY_BOOKMARKS: + // probably just means we have an old Hg version: simply don't + // display bookmarks + return; case ACT_MERGE: case ACT_RETRY_MERGE: MoreInformationDialog::information @@ -2227,11 +2238,15 @@ void MainWindow::commandCompleted(HgAction completedAction, QString output) { + std::cerr << "commandCompleted: " << completedAction.action << std::endl; + restoreFileSystemWatcher(); HGACTIONS action = completedAction.action; if (action == ACT_NONE) return; + output.replace("\r\n", "\n"); + bool headsChanged = false; QStringList oldHeadIds; @@ -2282,6 +2297,26 @@ m_currentBranch = output.trimmed(); break; + case ACT_QUERY_BOOKMARKS: + { + m_bookmarks.clear(); + QStringList outList = output.split('\n', QString::SkipEmptyParts); + foreach (QString line, outList) { + QStringList items = line.split(' ', QString::SkipEmptyParts); + if (items[0] == "*") { + if (items.size() == 3) { + m_bookmarks[items[2]].push_back(items[1]); + } + } else { + if (items.size() == 2) { + m_bookmarks[items[1]].push_back(items[0]); + } + } + } + m_hgTabs->setBookmarks(m_bookmarks); + break; + } + case ACT_STAT: m_lastStatOutput = output; updateFileSystemWatcher(); @@ -2436,7 +2471,6 @@ case ACT_DIFF_SUMMARY: { // Output has log info first, diff following after a blank line - output.replace("\r\n", "\n"); QStringList olist = output.split("\n\n", QString::SkipEmptyParts); if (olist.size() > 1) output = olist[1]; @@ -2495,11 +2529,12 @@ } // Sequence when no full log required: - // paths -> branch -> stat -> resolve-list -> heads -> + // paths -> branch -> stat -> bookmarks -> resolve-list -> heads -> // incremental-log (only if heads changed) -> parents // // Sequence when full log required: - // paths -> branch -> stat -> resolve-list -> heads -> parents -> log + // paths -> branch -> stat -> bookmarks -> resolve-list -> heads -> + // parents -> log // // Note we want to call enableDisableActions only once, at the end // of whichever sequence is in use. @@ -2530,17 +2565,23 @@ break; case ACT_QUERY_PATHS: + // NB this call is duplicated in hgQueryPaths hgQueryBranch(); break; case ACT_QUERY_BRANCH: + // NB this call is duplicated in hgQueryBranch hgStat(); break; case ACT_STAT: + hgQueryBookmarks(); + break; + + case ACT_QUERY_BOOKMARKS: hgResolveList(); break; - + case ACT_RESOLVE_LIST: hgQueryHeadsActive(); break; diff -r 5c846f3c9244 -r 000f13faa089 src/mainwindow.h --- a/src/mainwindow.h Thu Oct 20 15:39:46 2011 +0100 +++ b/src/mainwindow.h Tue Nov 08 16:42:09 2011 +0000 @@ -122,6 +122,7 @@ private: void hgQueryBranch(); + void hgQueryBookmarks(); void hgQueryHeadsActive(); void hgQueryHeads(); void hgQueryParents(); @@ -192,6 +193,7 @@ QString m_currentBranch; Changesets m_currentHeads; Changesets m_activeHeads; + QHash m_bookmarks; // changeset id -> names, not vice versa QSet m_closedHeadIds; Changesets m_currentParents; int m_commitsSincePush;