| ︙ | | |
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
-
+
-
+
|
a->setIconVisibleInMenu(false);
foreach(QAction *a, ui->menuFile->actions())
a->setIconVisibleInMenu(false);
#endif
viewMode = VIEWMODE_TREE;
loadSettings();
applySettings();
// Apply any explicit workspace path if available
if(workspacePath && !workspacePath->isEmpty())
openWorkspace(*workspacePath);
refresh();
rebuildRecent();
// Select the Root of the tree to update the file view
selectRootDir();
fossilAbort = false;
}
//------------------------------------------------------------------------------
MainWindow::~MainWindow()
{
stopUI();
saveSettings();
updateSettings();
// Dispose RepoFiles
for(filemap_t::iterator it = workspaceFiles.begin(); it!=workspaceFiles.end(); ++it)
delete *it;
delete ui;
}
|
| ︙ | | |
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
-
+
|
QString new_workspace = QFileInfo(workspace).absoluteFilePath();
currentWorkspace = new_workspace;
addWorkspace(new_workspace);
if(!QDir::setCurrent(new_workspace))
QMessageBox::critical(this, tr("Error"), tr("Could not change current diectory to '%0'").arg(new_workspace), QMessageBox::Ok );
QMessageBox::critical(this, tr("Error"), tr("Could not change current directory to '%0'").arg(new_workspace), QMessageBox::Ok );
}
//------------------------------------------------------------------------------
void MainWindow::addWorkspace(const QString &dir)
{
if(dir.isEmpty())
return;
|
| ︙ | | |
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
-
+
|
{
wkspace = fi.absoluteDir().absolutePath();
QString checkout_file1 = wkspace + PATH_SEP + FOSSIL_CHECKOUT1;
QString checkout_file2 = wkspace + PATH_SEP + FOSSIL_CHECKOUT2;
if(!(QFileInfo(checkout_file1).exists() || QFileInfo(checkout_file2).exists()) )
{
if(QMessageBox::Yes !=DialogQuery(this, tr("Open Fossil"), tr("A workspace does not exist in this folder.\nWould you like to create one here?")))
if(QMessageBox::Yes !=DialogQuery(this, tr("Open Workspace"), tr("A workspace does not exist in this folder.\nWould you like to create one here?")))
{
wkspace = QFileDialog::getExistingDirectory(
this,
tr("Select Workspace Folder"),
wkspace);
if(wkspace.isEmpty() || !QDir(wkspace).exists())
|
| ︙ | | |
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
-
+
|
return;
openWorkspace(path);
}
//------------------------------------------------------------------------------
void MainWindow::on_actionNewRepository_triggered()
{
QString filter(tr("Repositories (*.fossil)"));
QString filter(tr("Fossil Repositories (*.fossil)"));
// Get Repository file
QString repo_path = QFileDialog::getSaveFileName(
this,
tr("New Fossil Repository"),
QDir::currentPath(),
filter,
|
| ︙ | | |
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
|
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
|
-
+
|
enableActions(false);
repoFileModel.removeRows(0, repoFileModel.rowCount());
repoDirModel.clear();
return false;
}
else if(st==REPO_OLD_SCHEMA)
{
setStatus(tr("Old fossil schema detected. Consider running 'fossil rebuild'"));
setStatus(tr("Old repository schema detected. Consider running 'fossil rebuild'"));
enableActions(false);
repoFileModel.removeRows(0, repoFileModel.rowCount());
repoDirModel.clear();
return true;
}
loadFossilSettings();
|
| ︙ | | |
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
|
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
|
-
+
|
QCoreApplication::processEvents();
QString ignore;
// If we should not be showing ignored files, fill in the ignored spec
if(!ui->actionViewIgnored->isChecked())
{
// QDir expects multiple specs being separated by a semicolon
ignore = settings.Mappings[FUEL_SETTING_IGNORE_GLOB].Value.toString().replace(',',';');
ignore = settings.GetFossilValue(FOSSIL_SETTING_IGNORE_GLOB).toString().replace(',',';');
}
scanDirectory(all_files, wkdir, wkdir, ignore);
for(QFileInfoList::iterator it=all_files.begin(); it!=all_files.end(); ++it)
{
QString filename = it->fileName();
|
| ︙ | | |
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
|
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
|
-
+
|
// Create fossil process
LoggedProcess process(this);
process.setWorkingDirectory(wkdir);
process.start(fossil, args);
if(!process.waitForStarted())
{
log(tr("Could not start Fossil executable '%s'\n").arg(fossil));
log(tr("Could not start Fossil executable '%s'").arg(fossil)+"\n");
return false;
}
const QChar EOL_MARK('\n');
QString ans_yes = 'y' + EOL_MARK;
QString ans_no = 'n' + EOL_MARK;
QString ans_always = 'a' + EOL_MARK;
|
| ︙ | | |
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
|
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
|
-
+
-
+
-
-
-
+
-
-
-
-
-
-
+
-
-
+
+
-
+
-
+
-
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
-
-
-
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
|
}
//------------------------------------------------------------------------------
QString MainWindow::getFossilPath()
{
// Use the user-specified fossil if available
QString fossil_path = settings.Mappings[FUEL_SETTING_FOSSIL_PATH].Value.toString();
QString fossil_path = settings.GetValue(FUEL_SETTING_FOSSIL_PATH).toString();
if(!fossil_path.isEmpty())
return QDir::toNativeSeparators(fossil_path);
QString fossil_exe = "fossil";
#ifdef Q_WS_WIN32
fossil_exe += ".exe";
#endif
// Use our fossil if available
QString fuel_fossil = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QDir::separator() + fossil_exe);
if(QFile::exists(fuel_fossil))
return fuel_fossil;
// Otherwise assume there is a "fossil" executable in the path
return fossil_exe;
}
//------------------------------------------------------------------------------
void MainWindow::loadSettings()
void MainWindow::applySettings()
{
if(settings.store->contains(FUEL_SETTING_FOSSIL_PATH))
settings.Mappings[FUEL_SETTING_FOSSIL_PATH].Value = settings.store->value(FUEL_SETTING_FOSSIL_PATH);
QSettings *store = settings.GetStore();
if(settings.store->contains(FUEL_SETTING_COMMIT_MSG))
settings.Mappings[FUEL_SETTING_COMMIT_MSG].Value = settings.store->value(FUEL_SETTING_COMMIT_MSG);
if(settings.store->contains(FUEL_SETTING_FILE_DBLCLICK))
settings.Mappings[FUEL_SETTING_FILE_DBLCLICK].Value = settings.store->value(FUEL_SETTING_FILE_DBLCLICK);
int num_wks = settings.store->beginReadArray("Workspaces");
int num_wks = store->beginReadArray("Workspaces");
for(int i=0; i<num_wks; ++i)
{
settings.store->setArrayIndex(i);
QString wk = settings.store->value("Path").toString();
store->setArrayIndex(i);
QString wk = store->value("Path").toString();
// Skip invalid workspaces
if(wk.isEmpty() || !QDir(wk).exists())
continue;
addWorkspace(wk);
if(settings.store->contains("Active") && settings.store->value("Active").toBool())
if(store->contains("Active") && store->value("Active").toBool())
setCurrentWorkspace(wk);
}
settings.store->endArray();
store->endArray();
if(settings.store->contains("WindowX") && settings.store->contains("WindowY"))
if(store->contains("WindowX") && store->contains("WindowY"))
{
QPoint _pos;
_pos.setX(settings.store->value("WindowX").toInt());
_pos.setY(settings.store->value("WindowY").toInt());
_pos.setX(store->value("WindowX").toInt());
_pos.setY(store->value("WindowY").toInt());
move(_pos);
}
if(settings.store->contains("WindowWidth") && settings.store->contains("WindowHeight"))
if(store->contains("WindowWidth") && store->contains("WindowHeight"))
{
QSize _size;
_size.setWidth(settings.store->value("WindowWidth").toInt());
_size.setHeight(settings.store->value("WindowHeight").toInt());
_size.setWidth(store->value("WindowWidth").toInt());
_size.setHeight(store->value("WindowHeight").toInt());
resize(_size);
}
if(settings.store->contains("ViewUnknown"))
ui->actionViewUnknown->setChecked(settings.store->value("ViewUnknown").toBool());
if(settings.store->contains("ViewModified"))
ui->actionViewModified->setChecked(settings.store->value("ViewModified").toBool());
if(settings.store->contains("ViewUnchanged"))
ui->actionViewUnchanged->setChecked(settings.store->value("ViewUnchanged").toBool());
if(settings.store->contains("ViewIgnored"))
ui->actionViewIgnored->setChecked(settings.store->value("ViewIgnored").toBool());
if(settings.store->contains("ViewAsList"))
if(store->contains("ViewUnknown"))
ui->actionViewUnknown->setChecked(store->value("ViewUnknown").toBool());
if(store->contains("ViewModified"))
ui->actionViewModified->setChecked(store->value("ViewModified").toBool());
if(store->contains("ViewUnchanged"))
ui->actionViewUnchanged->setChecked(store->value("ViewUnchanged").toBool());
if(store->contains("ViewIgnored"))
ui->actionViewIgnored->setChecked(store->value("ViewIgnored").toBool());
if(store->contains("ViewAsList"))
{
ui->actionViewAsList->setChecked(settings.store->value("ViewAsList").toBool());
viewMode = settings.store->value("ViewAsList").toBool()? VIEWMODE_LIST : VIEWMODE_TREE;
ui->actionViewAsList->setChecked(store->value("ViewAsList").toBool());
viewMode = store->value("ViewAsList").toBool()? VIEWMODE_LIST : VIEWMODE_TREE;
}
ui->treeView->setVisible(viewMode == VIEWMODE_TREE);
if(settings.store->contains("ViewStash"))
ui->actionViewStash->setChecked(settings.store->value("ViewStash").toBool());
if(store->contains("ViewStash"))
ui->actionViewStash->setChecked(store->value("ViewStash").toBool());
ui->tableViewStash->setVisible(ui->actionViewStash->isChecked());
}
//------------------------------------------------------------------------------
void MainWindow::saveSettings()
void MainWindow::updateSettings()
{
// If we have a customize fossil path, save it
QString fossil_path = settings.Mappings[FUEL_SETTING_FOSSIL_PATH].Value.toString();
QSettings *store = settings.GetStore();
settings.store->setValue(FUEL_SETTING_FOSSIL_PATH, fossil_path);
settings.store->setValue(FUEL_SETTING_COMMIT_MSG, settings.Mappings[FUEL_SETTING_COMMIT_MSG].Value);
settings.store->setValue(FUEL_SETTING_FILE_DBLCLICK, settings.Mappings[FUEL_SETTING_FILE_DBLCLICK].Value);
settings.store->beginWriteArray("Workspaces", workspaceHistory.size());
store->beginWriteArray("Workspaces", workspaceHistory.size());
for(int i=0; i<workspaceHistory.size(); ++i)
{
settings.store->setArrayIndex(i);
settings.store->setValue("Path", workspaceHistory[i]);
store->setArrayIndex(i);
store->setValue("Path", workspaceHistory[i]);
if(getCurrentWorkspace() == workspaceHistory[i])
settings.store->setValue("Active", true);
store->setValue("Active", true);
else
settings.store->remove("Active");
store->remove("Active");
}
settings.store->endArray();
store->endArray();
settings.store->setValue("WindowX", x());
settings.store->setValue("WindowY", y());
settings.store->setValue("WindowWidth", width());
settings.store->setValue("WindowHeight", height());
settings.store->setValue("ViewUnknown", ui->actionViewUnknown->isChecked());
settings.store->setValue("ViewModified", ui->actionViewModified->isChecked());
settings.store->setValue("ViewUnchanged", ui->actionViewUnchanged->isChecked());
settings.store->setValue("ViewIgnored", ui->actionViewIgnored->isChecked());
settings.store->setValue("ViewAsList", ui->actionViewAsList->isChecked());
settings.store->setValue("ViewStash", ui->actionViewStash->isChecked());
store->setValue("WindowX", x());
store->setValue("WindowY", y());
store->setValue("WindowWidth", width());
store->setValue("WindowHeight", height());
store->setValue("ViewUnknown", ui->actionViewUnknown->isChecked());
store->setValue("ViewModified", ui->actionViewModified->isChecked());
store->setValue("ViewUnchanged", ui->actionViewUnchanged->isChecked());
store->setValue("ViewIgnored", ui->actionViewIgnored->isChecked());
store->setValue("ViewAsList", ui->actionViewAsList->isChecked());
store->setValue("ViewStash", ui->actionViewStash->isChecked());
}
//------------------------------------------------------------------------------
void MainWindow::selectRootDir()
{
if(viewMode==VIEWMODE_TREE)
{
|
| ︙ | | |
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
|
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
|
-
+
-
+
-
+
|
}
//------------------------------------------------------------------------------
bool MainWindow::startUI()
{
if(uiRunning())
{
log(tr("Fossil UI is already running\n"));
log(tr("Fossil UI is already running")+"\n");
return true;
}
fossilUI.setParent(this);
fossilUI.setProcessChannelMode(QProcess::MergedChannels);
fossilUI.setWorkingDirectory(getCurrentWorkspace());
log("<b>> fossil ui</b><br>", true);
log(tr("Starting Fossil browser UI. Please wait.\n"));
log(tr("Starting Fossil browser UI. Please wait.")+"\n");
QString fossil = getFossilPath();
fossilUI.start(fossil, QStringList() << "ui");
if(!fossilUI.waitForStarted() || fossilUI.state()!=QProcess::Running)
{
log(tr("Could not start Fossil executable '%s'\n").arg(fossil));
log(tr("Could not start Fossil executable '%s'").arg(fossil)+"\n");
ui->actionFossilUI->setChecked(false);
return false;
}
#if 0
QString buffer;
while(buffer.indexOf(EOL_MARK)==-1)
|
| ︙ | | |
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
|
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
|
-
+
|
QDesktopServices::openUrl(QUrl(getFossilHttpAddress()+"/finfo?name="+*it));
}
}
//------------------------------------------------------------------------------
void MainWindow::on_tableView_doubleClicked(const QModelIndex &/*index*/)
{
int action = settings.Mappings[FUEL_SETTING_FILE_DBLCLICK].Value.toInt();
int action = settings.GetValue(FUEL_SETTING_FILE_DBLCLICK).toInt();
if(action==FILE_DLBCLICK_ACTION_DIFF)
on_actionDiff_triggered();
else if(action==FILE_DLBCLICK_ACTION_OPEN)
on_actionOpenFile_triggered();
else if(action==FILE_DLBCLICK_ACTION_OPENCONTAINING)
on_actionOpenContaining_triggered();
}
|
| ︙ | | |
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
|
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
|
-
+
-
+
-
+
-
+
|
QDesktopServices::openUrl(QUrl::fromLocalFile(getCurrentWorkspace()+QDir::separator()+*it));
}
}
//------------------------------------------------------------------------------
void MainWindow::on_actionPush_triggered()
{
QString remote_url = settings.Mappings[FUEL_SETTING_REMOTE_URL].Value.toString();
QString remote_url = settings.GetFossilValue(FOSSIL_SETTING_REMOTE_URL).toString();
if(remote_url.isEmpty() || remote_url == "off")
{
QMessageBox::critical(this, tr("Error"), tr("A remote repository has not been specified.\nUse the preferences window to set the remote repostory location"), QMessageBox::Ok );
return;
}
runFossil(QStringList() << "push");
}
//------------------------------------------------------------------------------
void MainWindow::on_actionPull_triggered()
{
QString remote_url = settings.Mappings[FUEL_SETTING_REMOTE_URL].Value.toString();
QString remote_url = settings.GetFossilValue(FOSSIL_SETTING_REMOTE_URL).toString();
if(remote_url.isEmpty() || remote_url == "off")
{
QMessageBox::critical(this, tr("Error"), tr("A remote repository has not been specified.\nUse the preferences window to set the remote repostory location"), QMessageBox::Ok );
return;
}
runFossil(QStringList() << "pull");
}
//------------------------------------------------------------------------------
void MainWindow::on_actionCommit_triggered()
{
QStringList commit_files;
getSelectionFilenames(commit_files, RepoFile::TYPE_MODIFIED, true);
if(commit_files.empty())
return;
QStringList commit_msgs = settings.Mappings[FUEL_SETTING_COMMIT_MSG].Value.toStringList();
QStringList commit_msgs = settings.GetValue(FUEL_SETTING_COMMIT_MSG).toStringList();
QString msg;
bool aborted = !CommitDialog::run(this, tr("Commit Changes"), commit_files, msg, &commit_msgs);
// Aborted or not we always keep the commit messages.
// (This has saved me way too many times on TortoiseSVN)
if(commit_msgs.indexOf(msg)==-1)
{
commit_msgs.push_front(msg);
settings.Mappings[FUEL_SETTING_COMMIT_MSG].Value = commit_msgs;
settings.SetValue(FUEL_SETTING_COMMIT_MSG, commit_msgs);
}
if(aborted)
return;
// Since via the commit dialog the user can deselect all files
if(commit_files.empty())
|
| ︙ | | |
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
|
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
|
-
+
|
if(repo_files.length()!=1)
return;
QFileInfo fi_before(repo_files[0]);
bool ok = false;
QString new_name = QInputDialog::getText(this, tr("Rename"), tr("Enter new name"), QLineEdit::Normal, fi_before.filePath(), &ok, Qt::Sheet );
QString new_name = QInputDialog::getText(this, tr("Rename"), tr("New name"), QLineEdit::Normal, fi_before.filePath(), &ok, Qt::Sheet );
if(!ok)
return;
QFileInfo fi_after(new_name);
if(fi_after.exists())
{
|
| ︙ | | |
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
|
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
|
-
+
|
fossil_ver = tr("Fossil version %0").arg(res[0].mid(off)) + "\n\n";
}
QMessageBox::about(this, tr("About Fuel..."),
QCoreApplication::applicationName() + " "+ QCoreApplication::applicationVersion() + " " +
tr("a GUI frontend to the Fossil SCM\n"
"by Kostas Karanikolas\n"
"Released under the GNU GPL\n\n")
"Released under the GNU GPL")+"\n\n"
+ fossil_ver +
tr("Icon-set by Deleket - Jojo Mendoza\n"
"Available under the CC Attribution Noncommercial No Derivate 3.0 License"));
}
//------------------------------------------------------------------------------
void MainWindow::on_actionUpdate_triggered()
|
| ︙ | | |
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
|
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
|
-
+
-
-
-
-
|
// Also retrieve the fossil global settings
QStringList out;
if(!runFossil(QStringList() << "settings", &out, RUNGLAGS_SILENT_ALL))
return;
QStringMap kv = MakeKeyValues(out);
for(Settings::mappings_t::iterator it=settings.Mappings.begin(); it!=settings.Mappings.end(); ++it)
for(Settings::mappings_t::iterator it=settings.GetMappings().begin(); it!=settings.GetMappings().end(); ++it)
{
const QString &name = it.key();
Settings::Setting::SettingType type = it->Type;
// Internal types are handled explicitly
if(type == Settings::Setting::TYPE_INTERNAL)
continue;
// Command types we issue directly on fossil
if(type == Settings::Setting::TYPE_FOSSIL_COMMAND)
{
// Retrieve existing url
QStringList out;
if(runFossil(QStringList() << name, &out, RUNGLAGS_SILENT_ALL) && out.length()==1)
it.value().Value = out[0].trimmed();
|
| ︙ | | |
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
|
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
|
-
+
-
-
-
-
|
loadFossilSettings();
// Run the dialog
if(!SettingsDialog::run(this, settings))
return;
// Apply settings
for(Settings::mappings_t::iterator it=settings.Mappings.begin(); it!=settings.Mappings.end(); ++it)
for(Settings::mappings_t::iterator it=settings.GetMappings().begin(); it!=settings.GetMappings().end(); ++it)
{
const QString &name = it.key();
Settings::Setting::SettingType type = it.value().Type;
// Internal types are handled explicitly
if(type == Settings::Setting::TYPE_INTERNAL)
continue;
// Command types we issue directly on fossil
if(type == Settings::Setting::TYPE_FOSSIL_COMMAND)
{
// Run as silent to avoid displaying credentials in the log
runFossil(QStringList() << "remote-url" << QuotePath(it.value().Value.toString()), 0, RUNGLAGS_SILENT_INPUT);
continue;
}
|
| ︙ | | |
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
|
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
|
-
+
-
+
-
+
|
dir_start = 0;
else
++dir_start;
QString old_name = old_path.mid(dir_start);
bool ok = false;
QString new_name = QInputDialog::getText(this, tr("Rename Folder"), tr("Enter new name"), QLineEdit::Normal, old_name, &ok, Qt::Sheet);
QString new_name = QInputDialog::getText(this, tr("Rename Folder"), tr("New name"), QLineEdit::Normal, old_name, &ok, Qt::Sheet);
if(!ok || old_name==new_name)
return;
const char* invalid_tokens[] = {
"/", "\\", "\\\\", ":", ">", "<", "*", "?", "|", "\"", ".."
};
for(size_t i=0; i<COUNTOF(invalid_tokens); ++i)
{
if(new_name.indexOf(invalid_tokens[i])!=-1)
{
QMessageBox::critical(this, tr("Error"), tr("Cannot rename folder.\nFolder name contains invalid characters."));
QMessageBox::critical(this, tr("Error"), tr("Cannot rename folder.")+"\n" +tr("Folder name contains invalid characters."));
return;
}
}
QString new_path = old_path.left(dir_start) + new_name;
if(pathSet.contains(new_path))
{
QMessageBox::critical(this, tr("Error"), tr("Cannot rename folder.\nThis folder exists already."));
QMessageBox::critical(this, tr("Error"), tr("Cannot rename folder.")+"\n" +tr("This folder exists already."));
return;
}
// Collect the files to be moved
filelist_t files_to_move;
QStringList new_paths;
QStringList operations;
|
| ︙ | | |
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
|
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
|
-
+
-
+
-
+
-
+
-
+
-
+
|
for(int i=0; i<files_to_move.length(); ++i)
{
RepoFile *r = files_to_move[i];
const QString &new_file_path = new_paths[i] + PATH_SEP + r->getFilename();
if(!runFossil(QStringList() << "mv" << QuotePath(r->getFilePath()) << QuotePath(new_file_path)))
{
log(tr("Move aborted due to errors\n"));
log(tr("Move aborted due to errors")+"\n");
goto _exit;
}
}
if(!move_local)
goto _exit;
// First ensure that the target directories exist, and if not make them
for(int i=0; i<files_to_move.length(); ++i)
{
QString target_path = QDir::cleanPath(getCurrentWorkspace() + PATH_SEP + new_paths[i] + PATH_SEP);
QDir target(target_path);
if(target.exists())
continue;
QDir wkdir(getCurrentWorkspace());
Q_ASSERT(wkdir.exists());
log(tr("Creating folder '%0'\n").arg(target_path));
log(tr("Creating folder '%0'").arg(target_path)+"\n");
if(!wkdir.mkpath(new_paths[i] + PATH_SEP + "."))
{
QMessageBox::critical(this, tr("Error"), tr("Cannot make target folder '%0'\n").arg(target_path));
QMessageBox::critical(this, tr("Error"), tr("Cannot make target folder '%0'").arg(target_path));
goto _exit;
}
}
// Now that target directories exist copy files
for(int i=0; i<files_to_move.length(); ++i)
{
RepoFile *r = files_to_move[i];
QString new_file_path = new_paths[i] + PATH_SEP + r->getFilename();
if(QFile::exists(new_file_path))
{
QMessageBox::critical(this, tr("Error"), tr("Target file '%0' exists already").arg(new_file_path));
goto _exit;
}
log(tr("Copying file '%0' to '%1'\n").arg(r->getFilePath(), new_file_path));
log(tr("Copying file '%0' to '%1'").arg(r->getFilePath(), new_file_path)+"\n");
if(!QFile::copy(r->getFilePath(), new_file_path))
{
QMessageBox::critical(this, tr("Error"), tr("Cannot copy file '%0' to '%1'").arg(r->getFilePath(), new_file_path));
goto _exit;
}
}
// Finally delete old files
for(int i=0; i<files_to_move.length(); ++i)
{
RepoFile *r = files_to_move[i];
log(tr("Removing old file '%0'\n").arg(r->getFilePath()));
log(tr("Removing old file '%0'").arg(r->getFilePath())+"\n");
if(!QFile::exists(r->getFilePath()))
{
QMessageBox::critical(this, tr("Error"), tr("Source file '%0' does not exist").arg(r->getFilePath()));
goto _exit;
}
if(!QFile::remove(r->getFilePath()))
{
QMessageBox::critical(this, tr("Error"), tr("Cannot remove file '%0'").arg(r->getFilePath()));
goto _exit;
}
}
log(tr("Folder renamed completed. Don't forget to commit!\n"));
log(tr("Folder renamed completed. Don't forget to commit!")+"\n");
_exit:
refresh();
}
//------------------------------------------------------------------------------
QMenu * MainWindow::createPopupMenu()
|
| ︙ | | |
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
|
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
|
-
+
-
+
|
for(QStringList::iterator it=stashes.begin(); it!=stashes.end(); ++it)
{
stashmap_t::iterator id_it = stashMap.find(*it);
Q_ASSERT(id_it!=stashMap.end());
if(!runFossil(QStringList() << "stash" << "apply" << *id_it))
{
log(tr("Stash application aborted due to errors\n"));
log(tr("Stash application aborted due to errors")+"\n");
return;
}
}
// Delete stashes
for(QStringList::iterator it=stashes.begin(); delete_stashes && it!=stashes.end(); ++it)
{
stashmap_t::iterator id_it = stashMap.find(*it);
Q_ASSERT(id_it!=stashMap.end());
if(!runFossil(QStringList() << "stash" << "drop" << *id_it))
{
log(tr("Stash deletion aborted due to errors\n"));
log(tr("Stash deletion aborted due to errors")+"\n");
return;
}
}
refresh();
}
|
| ︙ | | |
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
|
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
|
-
+
|
for(QStringList::iterator it=stashes.begin(); it!=stashes.end(); ++it)
{
stashmap_t::iterator id_it = stashMap.find(*it);
Q_ASSERT(id_it!=stashMap.end());
if(!runFossil(QStringList() << "stash" << "drop" << *id_it))
{
log(tr("Stash deletion aborted due to errors\n"));
log(tr("Stash deletion aborted due to errors")+"\n");
return;
}
}
refresh();
}
|
| ︙ | | |