# # # patch "NEWS" # from [14fe4cce36d4542fe77716c95f443d4142362640] # to [ea03d1c9b0c26b701b56a1e217213eaadaa7106c] # # patch "res/forms/dialogs/commit_revision.ui" # from [1a36a633839e25b12d841e254c43bc769d335556] # to [2c0734fd54f2c82930aee762de7c7dc8f4cec001] # # patch "src/monotone/MonotoneUtil.cpp" # from [072706516496c20dfdee2d8aef7687233415559d] # to [bfebdb733f088ed3707d9ffaf755575ce3a48d18] # # patch "src/monotone/MonotoneUtil.h" # from [6d598f1f7692ade5b5ecf4f1072d1f6040cba5f7] # to [6650b2c4ebddee165d9c7e3acb7d8fd2743e9d1c] # # patch "src/view/dialogs/CommitRevision.cpp" # from [91edc558e873b06025c97375fdabcfa3fe4c369a] # to [6a1ded9f563047b3a5f57ad350af07255c6a7417] # ============================================================ --- NEWS 14fe4cce36d4542fe77716c95f443d4142362640 +++ NEWS ea03d1c9b0c26b701b56a1e217213eaadaa7106c @@ -1,5 +1,6 @@ ????-??-?? (0.10) - new: create / initialize new monotone databases + - new: directly select the key to sign a revision with in the commit dialog - bugfix: no longer crash the changeset browser when a database contains no revisions and the user clicks on "more/all changes" ============================================================ --- res/forms/dialogs/commit_revision.ui 1a36a633839e25b12d841e254c43bc769d335556 +++ res/forms/dialogs/commit_revision.ui 2c0734fd54f2c82930aee762de7c7dc8f4cec001 @@ -1,66 +1,67 @@ - + + CommitRevision - - + + 0 0 - 417 - 513 + 387 + 531 - + Commit revision - + - - + + Qt::Vertical - - + + Changes to commit - + - + - - + + Display changes against parent - + - - + + true - + QAbstractItemView::SingleSelection - + false - + false - + - - + + Qt::Horizontal - + 40 20 @@ -69,23 +70,23 @@ - - + + 11 - + Double-click on a patch to open the diff dialog. - - + + Qt::Horizontal - + 40 20 @@ -97,25 +98,25 @@ - - + + Changelog entry - + - + - + - - + + Previous changelog entries - + @@ -124,39 +125,39 @@ - - - - - use alternative branch + + + QFormLayout::AllNonFixedFieldsGrow + + + + + key to sign this commit - - - - Qt::Horizontal + + + + + + + use alternative branch - - - 40 - 20 - - - + - - - + + + false - - + + 0 0 - + 200 0 @@ -164,42 +165,25 @@ - - - - - - - + + + use alternative author - - - - Qt::Horizontal - - - - 16 - 20 - - - - - - - + + + false - - + + 0 0 - + 200 0 @@ -210,11 +194,11 @@ - - + + Qt::Horizontal - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -230,13 +214,13 @@ Splitter QSplitter -
Splitter.h
+
Splitter.h
1
ChangeLogEdit QTextEdit -
ChangeLogEdit.h
+
ChangeLogEdit.h
@@ -247,11 +231,11 @@ altAuthor setEnabled(bool) - + 100 514 - + 456 515 @@ -263,11 +247,11 @@ altBranch setEnabled(bool) - + 109 481 - + 456 484 @@ -279,11 +263,11 @@ CommitRevision reject() - + 302 541 - + 252 561 @@ -295,11 +279,11 @@ CommitRevision accept() - + 411 543 - + 392 560 ============================================================ --- src/monotone/MonotoneUtil.cpp 072706516496c20dfdee2d8aef7687233415559d +++ src/monotone/MonotoneUtil.cpp bfebdb733f088ed3707d9ffaf755575ce3a48d18 @@ -289,43 +289,53 @@ FileEntryList MonotoneUtil::getRevisionM return entries; } -QStringList MonotoneUtil::getPrivateKeyList(const DatabaseFile & db) +QMap MonotoneUtil::getPrivateKeyList(const DatabaseFile & db) { MonotoneTask in(QStringList() << "keys"); MonotoneTask out = runSynchronousDatabaseTask(db, in); if (!out.isFinished()) F("task aborted"); + QMap keys; + QString data = out.getDecodedOutput(); if (out.getReturnCode() > 0) { C(QString("Couldn't query keys: %1").arg(data)); - return QStringList(); + return keys; } BasicIOParser parser(data); if (!parser.parse()) { C("Could not parse basic_io."); - return QStringList(); + return keys; } - QStringList keys; StanzaList stanzas = parser.getStanzas(); foreach (const Stanza & st, stanzas) { - QString lastKey; + QString lastHash; + QString lastGivenName; + foreach (const StanzaEntry & en, st) { - if (en.sym == "name") + if (en.sym == "hash") { - lastKey = en.vals.at(0); + lastHash = en.hash; continue; } + if (en.sym == "given_name") + { + lastGivenName = en.vals.at(0); + continue; + } + if (en.sym == "private_location") { - I(!lastKey.isEmpty()); - keys.append(lastKey); + I(!lastHash.isEmpty() && !lastGivenName.isEmpty()); + keys.insert(lastHash, QObject::tr("%1 (%2...)") + .arg(lastGivenName).arg(lastHash.left(8))); break; } } @@ -448,6 +458,41 @@ bool MonotoneUtil::getAttribute(const Da return false; } +QMap MonotoneUtil::getDatabaseVariables(const DatabaseFile & db, + const QString & domain) +{ + QStringList args; + args << "get_db_variables" << domain; + MonotoneTask in(args); + MonotoneTask out = runSynchronousDatabaseTask(db, in); + if (!out.isFinished()) F("task aborted"); + + QMap entries; + + QString data = out.getDecodedOutput(); + if (out.getReturnCode() > 0) + { + C(QString("Couldn't run get_db_variables: %1").arg(data)); + return entries; + } + + BasicIOParser parser(data); + I(parser.parse()); + StanzaList stanzas = parser.getStanzas(); + + if (stanzas.size() > 0) + { + foreach (StanzaEntry st, stanzas.at(0)) + { + if (st.sym == "domain") continue; + I(st.sym == "entry" && st.vals.size() == 2); + entries.insert(st.vals[0], st.vals[1]); + } + } + + return entries; +} + /*! Strips mtn: warning: and alike from error strings coming from mtn and unwraps them, if this fails we add the original string unwrapped ============================================================ --- src/monotone/MonotoneUtil.h 6d598f1f7692ade5b5ecf4f1072d1f6040cba5f7 +++ src/monotone/MonotoneUtil.h 6650b2c4ebddee165d9c7e3acb7d8fd2743e9d1c @@ -38,12 +38,13 @@ public: static QStringList resolveSelector(const DatabaseFile &, const QString &); static RevisionCerts getRevisionCerts(const DatabaseFile &, const QString &); static FileEntryList getRevisionManifest(const DatabaseFile &, const QString &); - static QStringList getPrivateKeyList(const DatabaseFile &); + static QMap getPrivateKeyList(const DatabaseFile &); static QStringList getPreviousContentMarks(const DatabaseFile &, const QString &, const QString &); static QString getFileId(const DatabaseFile &, const QString &); static QStringList topsortRevisions(const DatabaseFile &, const QStringList &); static bool getAttribute(const WorkspacePath &, const QString &, const QString &, QPair &); static bool getAttribute(const DatabaseFile &, const QString &, const QString &, const QString &, QString &); + static QMap getDatabaseVariables(const DatabaseFile &, const QString &); // FIXME: decide what to do with that static QString stripMtnPrefix(const QString &); ============================================================ --- src/view/dialogs/CommitRevision.cpp 91edc558e873b06025c97375fdabcfa3fe4c369a +++ src/view/dialogs/CommitRevision.cpp 6a1ded9f563047b3a5f57ad350af07255c6a7417 @@ -90,6 +90,29 @@ void CommitRevision::readWorkspaceRevisi previousChangelogEntryList, SIGNAL(currentIndexChanged(int)), this, SLOT(setChangelogEntryFromList(int)) ); + + QMap privateKeys = + MonotoneUtil::getPrivateKeyList(MonotoneUtil::getDatabaseFile(workspacePath)); + + if (privateKeys.size() == 0) + { + QMessageBox::critical( + this, + tr("No private key found"), + tr("There are no private keys available with which to sign your " + "commit. Please go to Database > Key Management and create a " + "new private key first."), + QMessageBox::Ok + ); + done(0); + return; + } + + for (QMap::const_iterator it = privateKeys.constBegin(); + it != privateKeys.constEnd(); it++) + { + keys->addItem(it.value(), it.key()); + } } void CommitRevision::setChangelogEntryFromList(int index) @@ -158,39 +181,8 @@ void CommitRevision::accept() author = altAuthorStr; } - QStringList keys = MonotoneUtil::getPrivateKeyList(MonotoneUtil::getDatabaseFile(workspacePath)); + QString selectedKey = keys->itemData(keys->currentIndex()).toString(); - if (keys.size() == 0) - { - QMessageBox::critical( - this, - tr("No private key found"), - tr("There are no private keys available with which to sign your " - "commit. Please go to Database > Key Management and create a " - "new private key first."), - QMessageBox::Ok - ); - buttonBox->setEnabled(true); - return; - } - - QString selectedKey = keys.at(0); - - if (keys.size() > 1) - { - bool ok; - QString key = QInputDialog::getItem( - this, tr("Please select a key"), - tr("More than one private key is available.\n" - "Please select the key with which you like to sign this commit:"), - keys, 0, false, &ok); - if (key.isEmpty() || !ok) - { - return; - } - selectedKey = key; - } - WorkspaceCommitter committer(workspacePath, revModel); if (!committer.run(selectedKey, branch, author, changelogEntry->toPlainText()))