From dbaf78d164f069365b58ee1ab599837b20bd4b00 Mon Sep 17 00:00:00 2001 From: kostas Date: Sun, 22 Apr 2012 05:57:52 +0000 Subject: [PATCH 1/2] Increased robustness in the stash parsing FossilOrigin-Name: ce3816871d40d08821944aa58329baf993fcb688 --- MainWindow.cpp | 35 +++++++++++++++++++++++------------ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/MainWindow.cpp b/MainWindow.cpp index dcd8b55..94f4dd5 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -664,26 +664,37 @@ void MainWindow::scanWorkspace() if(!runFossil(QStringList() << "stash" << "ls", &res, RUNGLAGS_SILENT_ALL)) return; - for(QStringList::iterator line_it=res.begin(); line_it!=res.end(); ++line_it) - { - QString l = (*line_it).trimmed(); - int colon = l.indexOf(':'); + // 19: [5c46757d4b9765] on 2012-04-22 04:41:15 + QRegExp stash_rx("\\s*(\\d+):\\s+\\[(.*)\\] on (\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)", Qt::CaseInsensitive); - // When no colon we have no stash to process - if(colon==-1) + for(QStringList::iterator line_it=res.begin(); line_it!=res.end();) + { + QString line = *line_it; + + int index = stash_rx.indexIn(line); + if(index==-1) break; - QString id = l.left(colon); + QString id = stash_rx.cap(1); // Parse stash name ++line_it; + line = *line_it; - // Invalid stash, exit - if(line_it==res.end()) - break; + // Named stash + QString name; + // Finish at an anonymous stash or start of a new stash + if(line_it==res.end() || stash_rx.indexIn(line)!=-1) + { + name = tr("Stash %1").arg(id); + } + else + { + name = (*line_it); + name = name.trimmed(); + ++line_it; + } - QString name = (*line_it); - name = name.trimmed(); stashMap.insert(name, id); } diff --git a/manifest b/manifest index be99ed4..8a6f8d2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Allow\sopening\sa\sspecific\sworkspace\spath\sfrom\sthe\scommandline\n\n -D 2012-04-15T14:42:09.758 +C Increased\srobustness\sin\sthe\sstash\sparsing\n +D 2012-04-22T05:57:52.133 F CommitDialog.cpp a46020a9361151d8d286a2670257d01d8967bf69 F CommitDialog.h f1ee8db92103164e7db55a8407ccdcff24571b72 F CommitDialog.ui 813d7cba316e226de1a22b7e480bb969fbe9b0c4 @@ -8,7 +8,7 @@ F FileActionDialog.h 15db1650b3a13d70bc338371e4c033c66e3b79ce F FileActionDialog.ui c63644428579741aeb5fa052e237ba799ced9ad7 F FileTableView.cpp 5ddf8c391c9a3ac449ec61fb1db837b577afeec2 F FileTableView.h 03e56d87c2d46411b9762b87f4d301619aaf18df -F MainWindow.cpp 8d0d6d8e78210670a8fe533b1413bcbe77196ce1 +F MainWindow.cpp 865788d994bc7c132e8a2dc0ff8893bcf0230081 F MainWindow.h 78dc49fe4500a6113ed8bbff597d5305d203a80c F MainWindow.ui d569997fecf4a22d61a016a4a23eea04eaad6dee F SettingsDialog.cpp e1fad18cc020d08b82c6d35dc94f6624deec9a3b @@ -176,7 +176,7 @@ F installer/fuel.iss 13b6a938bcdf273cbd3649d2549887baa1577214 F installer/license.txt 4cc77b90af91e615a64ae04893fdffa7939db84c F main.cpp 69c1f9e873c016ef466d20298a67c3bc4c2b2f3a F resources.qrc e98383ed205f4e37100c60057e0129c3b86dea53 -P 8e08f86043f0c2159037824f125e6acf2c2be007 -R 2e9aacb62b629a4e755adad517f7f50b +P e42f476b1c07959ee224b1abbd60f811893d0717 +R f3af307696f374c7ed861ac0ac8da9ef U kostas -Z 528eba2e411becfe13a36cbfcfcf8dde +Z a39a161794cfc1b645b89f5c61f2466d diff --git a/manifest.uuid b/manifest.uuid index 9d65228..7b4182c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e42f476b1c07959ee224b1abbd60f811893d0717 \ No newline at end of file +ce3816871d40d08821944aa58329baf993fcb688 \ No newline at end of file From 3310e82765606b72cae861bddad6d9419916601c Mon Sep 17 00:00:00 2001 From: kostas Date: Sun, 22 Apr 2012 06:38:43 +0000 Subject: [PATCH 2/2] Prevent scanning of workspaces when we don't have a valid path Fixed invalid access in stash parsing FossilOrigin-Name: c346118e744ae9d9c397194a7aa29f42256d76db --- MainWindow.cpp | 22 ++++++++++------------ manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/MainWindow.cpp b/MainWindow.cpp index 94f4dd5..c9b1bdd 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -174,7 +174,7 @@ MainWindow::MainWindow(QWidget *parent, QString *workspacePath) : loadSettings(); // Apply any explict workspace path if available - if(workspacePath) + if(workspacePath && !workspacePath->isEmpty()) openWorkspace(*workspacePath); refresh(); @@ -540,6 +540,9 @@ void MainWindow::scanWorkspace() QFileInfoList all_files; QString wkdir = getCurrentWorkspace(); + if(wkdir.isEmpty()) + return; + // Retrieve the status of files tracked by fossil QStringList res; if(!runFossil(QStringList() << "ls" << "-l", &res, RUNGLAGS_SILENT_ALL)) @@ -667,7 +670,7 @@ void MainWindow::scanWorkspace() // 19: [5c46757d4b9765] on 2012-04-22 04:41:15 QRegExp stash_rx("\\s*(\\d+):\\s+\\[(.*)\\] on (\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)", Qt::CaseInsensitive); - for(QStringList::iterator line_it=res.begin(); line_it!=res.end();) + for(QStringList::iterator line_it=res.begin(); line_it!=res.end(); ) { QString line = *line_it; @@ -676,20 +679,15 @@ void MainWindow::scanWorkspace() break; QString id = stash_rx.cap(1); - - // Parse stash name ++line_it; - line = *line_it; - // Named stash QString name; - // Finish at an anonymous stash or start of a new stash - if(line_it==res.end() || stash_rx.indexIn(line)!=-1) - { - name = tr("Stash %1").arg(id); - } - else + // Finish at an anonymous stash or start of a new stash ? + if(line_it==res.end() || stash_rx.indexIn(*line_it)!=-1) + name = line.trimmed(); + else // Named stash { + // Parse stash name name = (*line_it); name = name.trimmed(); ++line_it; diff --git a/manifest b/manifest index 8a6f8d2..037e81b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Increased\srobustness\sin\sthe\sstash\sparsing\n -D 2012-04-22T05:57:52.133 +C Prevent\sscanning\sof\sworkspaces\swhen\swe\sdon't\shave\sa\svalid\spath\nFixed\sinvalid\saccess\sin\sstash\sparsing +D 2012-04-22T06:38:43.118 F CommitDialog.cpp a46020a9361151d8d286a2670257d01d8967bf69 F CommitDialog.h f1ee8db92103164e7db55a8407ccdcff24571b72 F CommitDialog.ui 813d7cba316e226de1a22b7e480bb969fbe9b0c4 @@ -8,7 +8,7 @@ F FileActionDialog.h 15db1650b3a13d70bc338371e4c033c66e3b79ce F FileActionDialog.ui c63644428579741aeb5fa052e237ba799ced9ad7 F FileTableView.cpp 5ddf8c391c9a3ac449ec61fb1db837b577afeec2 F FileTableView.h 03e56d87c2d46411b9762b87f4d301619aaf18df -F MainWindow.cpp 865788d994bc7c132e8a2dc0ff8893bcf0230081 +F MainWindow.cpp 63f43be93e02d1d962c8ccc48f0636f650eb0107 F MainWindow.h 78dc49fe4500a6113ed8bbff597d5305d203a80c F MainWindow.ui d569997fecf4a22d61a016a4a23eea04eaad6dee F SettingsDialog.cpp e1fad18cc020d08b82c6d35dc94f6624deec9a3b @@ -176,7 +176,7 @@ F installer/fuel.iss 13b6a938bcdf273cbd3649d2549887baa1577214 F installer/license.txt 4cc77b90af91e615a64ae04893fdffa7939db84c F main.cpp 69c1f9e873c016ef466d20298a67c3bc4c2b2f3a F resources.qrc e98383ed205f4e37100c60057e0129c3b86dea53 -P e42f476b1c07959ee224b1abbd60f811893d0717 -R f3af307696f374c7ed861ac0ac8da9ef +P ce3816871d40d08821944aa58329baf993fcb688 +R a76899b07d39493ca860fc54fea19753 U kostas -Z a39a161794cfc1b645b89f5c61f2466d +Z 22648ec8a9e0699bb52539c8c454dde9 diff --git a/manifest.uuid b/manifest.uuid index 7b4182c..ec31e0d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ce3816871d40d08821944aa58329baf993fcb688 \ No newline at end of file +c346118e744ae9d9c397194a7aa29f42256d76db \ No newline at end of file