#
#
# patch "res/forms/dialogs/source_picker.ui"
# from [73b28cf3513fc82065e93d9123309c1f42b0f8c7]
# to [c799ccc2943bbbb0f506f858d0faf03d453b78af]
#
# patch "src/monotone/MonotoneHandle.cpp"
# from [e0ecd3e20d26676662aef0e6db80d995affc123a]
# to [a67ad78635e27ea64d5b57f7f4b844511fb9254d]
#
# patch "src/monotone/MonotoneHandle.h"
# from [b4216f23afadeb16b99423faaeddafa99d365de1]
# to [938597f3e533c97e3f5c0d2423b3242ba5b40041]
#
# patch "src/monotone/MonotoneManager.cpp"
# from [e799ccaabc21a843e664ae4c620824dfe70a7bf9]
# to [e673935dc8f05af16c4527e88e9ccfd9e4ec3494]
#
# patch "src/monotone/MonotoneProcess.cpp"
# from [cad863bf78ebbd3f915be62ed4fcc38606d2d68a]
# to [07173c374e3a277def7fe20df810b189ac492591]
#
# patch "src/monotone/MonotoneUtil.cpp"
# from [9f6c42f935b4950dbed92cf6681ad56d4d49eb18]
# to [32fafcea1a6b614abe7dc08f9ed003cd8ceb76dd]
#
# patch "src/monotone/MonotoneUtil.h"
# from [95a654c700e6df18c743ccca374282d7ee7285d5]
# to [0df18e84f4603a218e32a753f62ec4a05730b758]
#
# patch "src/view/dialogs/CreateDatabase.cpp"
# from [27d181ca418dbbbf277d5740cf5d0830b20e9c46]
# to [d6e6917a121d20324cd10eb85443e0220f0c3788]
#
# patch "src/view/dialogs/SourcePicker.cpp"
# from [5e9177ff2b985d14559746b495bd96c1ab14b311]
# to [0b3bc52306b620e95357467d7c6b06b990fb9a4a]
#
# patch "src/view/mainwindows/ServerWindow.cpp"
# from [3c87001777b8618399754367c547927eba75eadf]
# to [95e24fe707f9002af347269a4d0b590374a22a7e]
#
# patch "src/view/mainwindows/ServerWindow.h"
# from [7887daf2f323b16802f47ee94d495955e927bdd5]
# to [f371d3676bb750c055ec07cb9fa21b89aa3bb781]
#
============================================================
--- res/forms/dialogs/source_picker.ui 73b28cf3513fc82065e93d9123309c1f42b0f8c7
+++ res/forms/dialogs/source_picker.ui c799ccc2943bbbb0f506f858d0faf03d453b78af
@@ -56,6 +56,9 @@
QAbstractItemView::DropOnly
+
+ Qt::ElideMiddle
+
false
============================================================
--- src/monotone/MonotoneHandle.cpp e0ecd3e20d26676662aef0e6db80d995affc123a
+++ src/monotone/MonotoneHandle.cpp a67ad78635e27ea64d5b57f7f4b844511fb9254d
@@ -17,13 +17,14 @@
***************************************************************************/
#include "MonotoneHandle.h"
-#include "MonotoneProcess.h"
+#include "MonotoneUtil.h"
#include "BasicIOParser.h"
#include
#include
QStringList MonotoneHandle::defaultDatabaseLocations;
+QMap MonotoneHandle::privateKeys;
MonotoneHandle::MonotoneHandle(Type t, const QString & d)
: type(t), data(d)
@@ -145,70 +146,23 @@ void MonotoneHandle::validatePrivateKey(
);
}
- QString output;
- QStringList args;
- args << "au" << "keys";
-
- if (!MonotoneProcess::singleRun(args, MonotoneHandlePtr(), output))
+ if (privateKeys.size() == 0)
{
- throw GuitoneException(
- QObject::tr("could not query private keys")
- );
+ privateKeys = MonotoneUtil::getPrivateKeyMap(MonotoneHandle::create());
}
- BasicIOParser parser(output);
- if (!parser.parse())
- {
- throw GuitoneException(
- QObject::tr("could not parse basic_io from key output")
- );
- }
+ QMap possibleKeys;
- QStringList possibleKeys;
-
- StanzaList stanzas = parser.getStanzas();
- foreach (const Stanza & st, stanzas)
+ QMapIterator it(privateKeys);
+ while (it.hasNext())
{
- QString keyHash;
- bool matched = false;
- bool isPrivate = false;
+ it.next();
- foreach (const StanzaEntry & sten, st)
+ if (it.key().indexOf(keyFragment) != -1 ||
+ it.value().indexOf(keyFragment) != -1)
{
- if (sten.sym == "hash")
- {
- keyHash = sten.hash;
- if (sten.hash.indexOf(keyFragment) != -1)
- {
- matched = true;
- }
- continue;
- }
-
- if (sten.sym == "given_name" || sten.sym == "local_name")
- {
- I(sten.vals.size() == 1);
- if (sten.vals.at(0).indexOf(keyFragment) != -1)
- {
- matched = true;
- }
- }
-
- // sanity, basically
- if (sten.sym == "private_location")
- {
- I(sten.vals.size() == 1);
- if (sten.vals.at(0) == "keystore")
- {
- isPrivate = true;
- }
- }
+ possibleKeys.insert(it.key(), it.value());
}
-
- if (matched && isPrivate)
- {
- possibleKeys.push_back(keyHash);
- }
}
if (possibleKeys.size() == 0)
@@ -222,11 +176,12 @@ void MonotoneHandle::validatePrivateKey(
{
throw GuitoneException(
QObject::tr("multiple private keys for fragment '%1' found:\n\t%2")
- .arg(keyFragment).arg(possibleKeys.join("\n\t"))
+ .arg(keyFragment)
+ .arg(QStringList(possibleKeys.values()).join("\n\t"))
);
}
- keyId = possibleKeys.at(0);
+ keyId = possibleKeys.constBegin().key();
}
void MonotoneHandle::validateServerConnection(const QString & host)
@@ -267,33 +222,19 @@ void MonotoneHandle::resolveDatabaseAlia
if (defaultDatabaseLocations.size() == 0)
{
- QString output;
- QStringList args;
- args << "au" << "lua"
- << "get_default_database_locations";
-
- if (MonotoneProcess::singleRun(args, MonotoneHandlePtr(), output))
- {
- QRegExp rx("\\[\\d+\\] = \"([^\"]+)\";");
-
- int pos = 0;
- while ((pos = rx.indexIn(output, pos)) != -1)
- {
- pos += rx.matchedLength();
- defaultDatabaseLocations.append(rx.cap(1));
- }
- }
+ defaultDatabaseLocations =
+ MonotoneUtil::getDefaultDatabaseLocations(MonotoneHandle::create());
}
foreach (const QString & defaultLocation, defaultDatabaseLocations)
{
- QFileInfo finfo(defaultLocation + "/" + alias);
- if (finfo.isFile())
- {
- database = finfo.canonicalFilePath();
- break;
- }
- }
+ QFileInfo finfo(defaultLocation + "/" + alias);
+ if (finfo.isFile())
+ {
+ database = finfo.canonicalFilePath();
+ break;
+ }
+ }
}
}
============================================================
--- src/monotone/MonotoneHandle.h b4216f23afadeb16b99423faaeddafa99d365de1
+++ src/monotone/MonotoneHandle.h 938597f3e533c97e3f5c0d2423b3242ba5b40041
@@ -50,6 +50,7 @@ private:
static void resolveDatabaseAlias(QString &);
static QStringList defaultDatabaseLocations;
+ static QMap privateKeys;
};
#endif
============================================================
--- src/monotone/MonotoneManager.cpp e799ccaabc21a843e664ae4c620824dfe70a7bf9
+++ src/monotone/MonotoneManager.cpp e673935dc8f05af16c4527e88e9ccfd9e4ec3494
@@ -69,6 +69,7 @@ MonotoneThreadPtr MonotoneManager::getTh
if (mtnPath.isEmpty())
throw GuitoneException(tr("Monotone binary path not set"));
+ I(handle);
QString ident = handle->identify();
QList threadIDs = identMap.keys(ident);
============================================================
--- src/monotone/MonotoneProcess.cpp cad863bf78ebbd3f915be62ed4fcc38606d2d68a
+++ src/monotone/MonotoneProcess.cpp 07173c374e3a277def7fe20df810b189ac492591
@@ -65,6 +65,7 @@ void MonotoneProcess::setMonotoneHandle(
void MonotoneProcess::setMonotoneHandle(const MonotoneHandlePtr & handle)
{
+ I(monotoneHandle->getType() != MonotoneHandle::server_handle);
monotoneHandle = handle;
}
@@ -85,23 +86,23 @@ void MonotoneProcess::start(const QStrin
finalParams << "--rcfile" << rcFile.fileName();
- if (!monotoneHandle.isNull())
+ if (monotoneHandle.isNull())
{
- I(monotoneHandle->getType() != MonotoneHandle::server_handle);
+ monotoneHandle = MonotoneHandle::create();
+ }
- // a somewhat reasonable path to choose to avoid side effects
- // like another existing monotone workspace
- QString workingDir = QDir::tempPath();
- if (monotoneHandle->getType() == MonotoneHandle::workspace_handle)
- {
- workingDir = monotoneHandle->getData();
- }
- setWorkingDirectory(workingDir);
+ // a somewhat reasonable path to choose to avoid side effects
+ // like another existing monotone workspace
+ QString workingDir = QDir::tempPath();
+ if (monotoneHandle->getType() == MonotoneHandle::workspace_handle)
+ {
+ workingDir = monotoneHandle->getData();
+ }
+ setWorkingDirectory(workingDir);
- if (monotoneHandle->getType() == MonotoneHandle::database_handle)
- {
- finalParams << "-d" << monotoneHandle->getData();
- }
+ if (monotoneHandle->getType() == MonotoneHandle::database_handle)
+ {
+ finalParams << "-d" << monotoneHandle->getData();
}
finalParams += params;
============================================================
--- src/monotone/MonotoneUtil.cpp 9f6c42f935b4950dbed92cf6681ad56d4d49eb18
+++ src/monotone/MonotoneUtil.cpp 32fafcea1a6b614abe7dc08f9ed003cd8ceb76dd
@@ -498,6 +498,40 @@ QStringList MonotoneUtil::getCommonAnces
return data.split('\n', QString::SkipEmptyParts);
}
+QStringList MonotoneUtil::getDefaultDatabaseLocations(const MonotoneHandlePtr & handle)
+{
+ QStringList args;
+ args << "lua" << "get_default_database_locations";
+
+ MonotoneTaskPtr task(new MonotoneTask(args));
+ runSynchronousTask(handle, task);
+ if (!task->isFinished())
+ {
+ C(QString("task '%1' aborted").arg(QString(task->getEncodedInput())));
+ return QStringList();
+ }
+
+ if (task->getReturnCode() > 0)
+ {
+ C(QString("Couldn't query default database locations: %1")
+ .arg(task->getLast(MonotoneTask::Error)));
+ return QStringList();
+ }
+
+ QString output = task->getDecodedOutput();
+ QStringList defaultLocations;
+ QRegExp rx("\\[\\d+\\] = \"([^\"]+)\";");
+
+ int pos = 0;
+ while ((pos = rx.indexIn(output, pos)) != -1)
+ {
+ pos += rx.matchedLength();
+ defaultLocations.append(rx.cap(1));
+ }
+
+ return defaultLocations;
+}
+
QStringList MonotoneUtil::getPreviousContentMarks(const MonotoneHandlePtr & handle,
const QString & file,
const QString & startRev)
============================================================
--- src/monotone/MonotoneUtil.h 95a654c700e6df18c743ccca374282d7ee7285d5
+++ src/monotone/MonotoneUtil.h 0df18e84f4603a218e32a753f62ec4a05730b758
@@ -46,6 +46,7 @@ public:
static QStringList getRoots(const MonotoneHandlePtr &, bool &);
static QStringList topsortRevisions(const MonotoneHandlePtr &, const QStringList &);
static QStringList getCommonAncestors(const MonotoneHandlePtr &, const QStringList &);
+ static QStringList getDefaultDatabaseLocations(const MonotoneHandlePtr &);
static bool getFileAttribute(const MonotoneHandlePtr &, const QString &, const QString &, const QString &, QPair &);
static QMap getDatabaseVariables(const MonotoneHandlePtr &, const QString &);
============================================================
--- src/view/dialogs/CreateDatabase.cpp 27d181ca418dbbbf277d5740cf5d0830b20e9c46
+++ src/view/dialogs/CreateDatabase.cpp d6e6917a121d20324cd10eb85443e0220f0c3788
@@ -99,7 +99,7 @@ void CreateDatabase::accept()
params << "db" << "init" << "-d" << filePath;
QString output;
- bool res = MonotoneProcess::singleRun(params, MonotoneHandlePtr(), output);
+ bool res = MonotoneProcess::singleRun(params, MonotoneHandle::create(), output);
if (!res)
{
============================================================
--- src/view/dialogs/SourcePicker.cpp 5e9177ff2b985d14559746b495bd96c1ab14b311
+++ src/view/dialogs/SourcePicker.cpp 0b3bc52306b620e95357467d7c6b06b990fb9a4a
@@ -75,6 +75,19 @@ SourcePicker::SourcePicker(QWidget * par
fsModel->iconProvider()->icon(QFileIconProvider::Folder));
places->addTopLevelItem(item);
+ QStringList defaultDatabaseLocations =
+ MonotoneUtil::getDefaultDatabaseLocations(MonotoneHandle::create());
+
+ foreach (const QString & defaultLocation, defaultDatabaseLocations)
+ {
+ QTreeWidgetItem * item = new QTreeWidgetItem(places);
+ item->setData(0, Qt::UserRole, defaultLocation);
+ item->setData(0, Qt::DisplayRole, defaultLocation);
+ item->setData(0, Qt::DecorationRole,
+ fsModel->iconProvider()->icon(QFileIconProvider::Folder));
+ places->addTopLevelItem(item);
+ }
+
QString initialPath = drives.at(0).absoluteFilePath();
fsModel->setRootPath(initialPath);
QModelIndex rootIndex = fsModel->index(initialPath);
============================================================
--- src/view/mainwindows/ServerWindow.cpp 3c87001777b8618399754367c547927eba75eadf
+++ src/view/mainwindows/ServerWindow.cpp 95e24fe707f9002af347269a4d0b590374a22a7e
@@ -16,25 +16,28 @@
* along with this program. If not, see . *
***************************************************************************/
+#include "vocab.h"
#include "ServerWindow.h"
#include "ServerMenuBar.h"
#include "ServerDialogManager.h"
#include "GuitoneCore.h"
#include "Settings.h"
+#include "MonotoneUtil.h"
#include
ServerWindow::ServerWindow() : MainWindow(),
- loadedServerLabel(0), revisionBrowser(0), netsyncDialog(0)
+ serverAddressLabel(0), privateKeyLabel(0), revisionBrowser(0), netsyncDialog(0)
{
setObjectName("ServerWindow");
}
ServerWindow::~ServerWindow()
{
- if (loadedServerLabel) delete loadedServerLabel;
- if (revisionBrowser) delete revisionBrowser;
- if (netsyncDialog) delete netsyncDialog;
+ if (serverAddressLabel) delete serverAddressLabel;
+ if (privateKeyLabel) delete privateKeyLabel;
+ if (revisionBrowser) delete revisionBrowser;
+ if (netsyncDialog) delete netsyncDialog;
}
void ServerWindow::init()
@@ -70,12 +73,14 @@ void ServerWindow::setup()
QWidget * centralWidget = new QWidget(this);
QVBoxLayout * vboxLayout = new QVBoxLayout(centralWidget);
- QGroupBox *loadedServerGroup = new QGroupBox(tr("Connected to server"), centralWidget);
+ QGroupBox *loadedServerGroup = new QGroupBox(tr("Server connection"), centralWidget);
vboxLayout->addWidget(loadedServerGroup);
QVBoxLayout * vboxLayout1 = new QVBoxLayout(loadedServerGroup);
- loadedServerLabel = new QLabel(tr("not connected"), this);
- vboxLayout1->addWidget(loadedServerLabel);
+ serverAddressLabel = new QLabel(tr("Server: %1").arg(tr("n/a")), this);
+ privateKeyLabel = new QLabel(tr("Authentication: %1").arg(tr("n/a")), this);
+ vboxLayout1->addWidget(serverAddressLabel);
+ vboxLayout1->addWidget(privateKeyLabel);
QGroupBox * actionGroup = new QGroupBox(tr("Actions"), centralWidget);
QVBoxLayout * vboxLayout2 = new QVBoxLayout(actionGroup);
@@ -111,8 +116,25 @@ void ServerWindow::load(const MonotoneHa
monotoneHandle = handle;
- loadedServerLabel->setText(handle->getData());
+ QString uri = handle->getData();
+ QRegExp rx("^mtn://(?:(\\w*)@)?([\\w\\-]+(?:\\.[\\w\\-]+)*(?::\\d+)?)$");
+ if (rx.indexIn(uri) != -1)
+ {
+ serverAddressLabel->setText(tr("Server: %1").arg(rx.cap(2)));
+ if (rx.cap(1).isEmpty())
+ {
+ privateKeyLabel->setText(tr("Authentication: %1").arg(""));
+ }
+ else
+ {
+ QMap map =
+ MonotoneUtil::getPrivateKeyMap(MonotoneHandle::create());
+ I(map.contains(rx.cap(1)));
+ privateKeyLabel->setText(tr("Authentication: %1").arg(map.value(rx.cap(1))));
+ }
+ }
+
setWindowTitle(
tr("%1 - server mode - guitone").arg(handle->getData())
);
============================================================
--- src/view/mainwindows/ServerWindow.h 7887daf2f323b16802f47ee94d495955e927bdd5
+++ src/view/mainwindows/ServerWindow.h f371d3676bb750c055ec07cb9fa21b89aa3bb781
@@ -38,7 +38,8 @@ protected:
protected:
MonotoneHandlePtr monotoneHandle;
- QLabel * loadedServerLabel;
+ QLabel * serverAddressLabel;
+ QLabel * privateKeyLabel;
QPushButton * revisionBrowser;
QPushButton * netsyncDialog;
};