Fuel

Diff
Login

Differences From Artifact [28f0155821]:

To Artifact [b94d6963f9]:


313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
	spacer->setMinimumWidth(3);
	ui->mainToolBar->addWidget(spacer);

	viewMode = VIEWMODE_TREE;

	uiCallback.init(this);
	// Need to be before applySettings which sets the last workspace
	fossil().Init(&uiCallback);
	fossil().setExecutablePath(settings.GetValue(FUEL_SETTING_FOSSIL_PATH).toString());

	applySettings();

	// Apply any explicit workspace path if available
	if(workspacePath && !workspacePath->isEmpty())
		openWorkspace(*workspacePath);








|
|







313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
	spacer->setMinimumWidth(3);
	ui->mainToolBar->addWidget(spacer);

	viewMode = VIEWMODE_TREE;

	uiCallback.init(this);
	// Need to be before applySettings which sets the last workspace
	getWorkspace().fossil().Init(&uiCallback);
	getWorkspace().fossil().setExecutablePath(settings.GetValue(FUEL_SETTING_FOSSIL_PATH).toString());

	applySettings();

	// Apply any explicit workspace path if available
	if(workspacePath && !workspacePath->isEmpty())
		openWorkspace(*workspacePath);

397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
							wkspace);

				if(wkspace.isEmpty() || !QDir(wkspace).exists())
					return false;
			}

			// Ok open the repository file
			if(!fossil().openRepository(fi.absoluteFilePath(), wkspace))
			{
				QMessageBox::critical(this, tr("Error"), tr("Could not open repository."), QMessageBox::Ok );
				return false;
			}

		}
		else







|







397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
							wkspace);

				if(wkspace.isEmpty() || !QDir(wkspace).exists())
					return false;
			}

			// Ok open the repository file
			if(!getWorkspace().fossil().openRepository(fi.absoluteFilePath(), wkspace))
			{
				QMessageBox::critical(this, tr("Error"), tr("Could not open repository."), QMessageBox::Ok );
				return false;
			}

		}
		else
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546

	stopUI();
	on_actionClearLog_triggered();

	// Create repository
	QString repo_abs_path = repo_path_info.absoluteFilePath();

	if(!fossil().newRepository(repo_abs_path))
	{
		QMessageBox::critical(this, tr("Error"), tr("Could not create repository."), QMessageBox::Ok );
		return;
	}

	if(!fossil().openRepository(repo_abs_path, wkdir))
	{
		QMessageBox::critical(this, tr("Error"), tr("Could not open repository."), QMessageBox::Ok );
		return;
	}

	// Disable unknown file filter
	if(!ui->actionViewUnknown->isChecked())
		ui->actionViewUnknown->setChecked(true);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionCloseRepository_triggered()
{
	if(fossil().getRepoStatus()!=REPO_OK)
		return;

	if(QMessageBox::Yes !=DialogQuery(this, tr("Close Workspace"), tr("Are you sure you want to close this workspace?")))
		return;

	// Close Repo
	if(!fossil().closeRepository())
	{
		QMessageBox::critical(this, tr("Error"), tr("Cannot close the workspace.\nAre there still uncommitted changes available?"), QMessageBox::Ok );
		return;
	}

	stopUI();
	setCurrentWorkspace("");







|





|















|






|







503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546

	stopUI();
	on_actionClearLog_triggered();

	// Create repository
	QString repo_abs_path = repo_path_info.absoluteFilePath();

	if(!getWorkspace().fossil().newRepository(repo_abs_path))
	{
		QMessageBox::critical(this, tr("Error"), tr("Could not create repository."), QMessageBox::Ok );
		return;
	}

	if(!getWorkspace().fossil().openRepository(repo_abs_path, wkdir))
	{
		QMessageBox::critical(this, tr("Error"), tr("Could not open repository."), QMessageBox::Ok );
		return;
	}

	// Disable unknown file filter
	if(!ui->actionViewUnknown->isChecked())
		ui->actionViewUnknown->setChecked(true);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionCloseRepository_triggered()
{
	if(getWorkspace().fossil().getRepoStatus()!=REPO_OK)
		return;

	if(QMessageBox::Yes !=DialogQuery(this, tr("Close Workspace"), tr("Are you sure you want to close this workspace?")))
		return;

	// Close Repo
	if(!getWorkspace().fossil().closeRepository())
	{
		QMessageBox::critical(this, tr("Error"), tr("Cannot close the workspace.\nAre there still uncommitted changes available?"), QMessageBox::Ok );
		return;
	}

	stopUI();
	setCurrentWorkspace("");
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
	QString repository;

	if(!CloneDialog::run(this, url, repository, url_proxy))
		return;

	stopUI();

	if(!fossil().cloneRepository(repository, url, url_proxy))
	{
		QMessageBox::critical(this, tr("Error"), tr("Could not clone the repository"), QMessageBox::Ok);
		return;
	}

	if(!openWorkspace(repository))
		return;







|







554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
	QString repository;

	if(!CloneDialog::run(this, url, repository, url_proxy))
		return;

	stopUI();

	if(!getWorkspace().fossil().cloneRepository(repository, url, url_proxy))
	{
		QMessageBox::critical(this, tr("Error"), tr("Could not clone the repository"), QMessageBox::Ok);
		return;
	}

	if(!openWorkspace(repository))
		return;
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
//------------------------------------------------------------------------------
bool MainWindow::scanWorkspace()
{
	setBusy(true);
	bool valid = true;

	// Load repository info
	RepoStatus st = fossil().getRepoStatus();
	QString status;

	if(st==REPO_NOT_FOUND)
	{
		status = tr("No workspace detected.");
		valid = false;
	}







|







685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
//------------------------------------------------------------------------------
bool MainWindow::scanWorkspace()
{
	setBusy(true);
	bool valid = true;

	// Load repository info
	RepoStatus st = getWorkspace().fossil().getRepoStatus();
	QString status;

	if(st==REPO_NOT_FOUND)
	{
		status = tr("No workspace detected.");
		valid = false;
	}
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
void MainWindow::fossilBrowse(const QString &fossilUrl)
{
	if(!uiRunning())
		ui->actionFossilUI->activate(QAction::Trigger);

	bool use_internal = settings.GetValue(FUEL_SETTING_WEB_BROWSER).toInt() == 1;

	QUrl url = QUrl(fossil().getUIHttpAddress()+fossilUrl);

	if(use_internal)
	{
		ui->webView->load(url);
		ui->tabWidget->setCurrentIndex(TAB_BROWSER);
	}
	else







|







1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
void MainWindow::fossilBrowse(const QString &fossilUrl)
{
	if(!uiRunning())
		ui->actionFossilUI->activate(QAction::Trigger);

	bool use_internal = settings.GetValue(FUEL_SETTING_WEB_BROWSER).toInt() == 1;

	QUrl url = QUrl(getWorkspace().fossil().getUIHttpAddress()+fossilUrl);

	if(use_internal)
	{
		ui->webView->load(url);
		ui->tabWidget->setCurrentIndex(TAB_BROWSER);
	}
	else
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
	}
}
//------------------------------------------------------------------------------
bool MainWindow::diffFile(const QString &repoFile)
{
	const QString &gdiff = settings.GetFossilValue(FOSSIL_SETTING_GDIFF_CMD).toString();
	if(!gdiff.isEmpty())
		return fossil().diffFile(repoFile, true);
	else
		return fossil().diffFile(repoFile, false);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionDiff_triggered()
{
	QStringList selection;
	getSelectionFilenames(selection, WorkspaceFile::TYPE_REPO);

	for(QStringList::iterator it = selection.begin(); it!=selection.end(); ++it)
		if(!diffFile(*it))
			return;
}

//------------------------------------------------------------------------------
bool MainWindow::startUI()
{
	bool started = fossil().startUI("");
	ui->actionFossilUI->setChecked(started);
	return started;
}
//------------------------------------------------------------------------------
void MainWindow::stopUI()
{
	fossil().stopUI();
	ui->webView->load(QUrl("about:blank"));
	ui->actionFossilUI->setChecked(false);
}

//------------------------------------------------------------------------------
bool MainWindow::uiRunning() const
{
	return fossil().uiRunning();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionFossilUI_triggered()
{
	if(!uiRunning() && ui->actionFossilUI->isChecked())
	{







|

|
















|






|







|







1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
	}
}
//------------------------------------------------------------------------------
bool MainWindow::diffFile(const QString &repoFile)
{
	const QString &gdiff = settings.GetFossilValue(FOSSIL_SETTING_GDIFF_CMD).toString();
	if(!gdiff.isEmpty())
		return getWorkspace().fossil().diffFile(repoFile, true);
	else
		return getWorkspace().fossil().diffFile(repoFile, false);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionDiff_triggered()
{
	QStringList selection;
	getSelectionFilenames(selection, WorkspaceFile::TYPE_REPO);

	for(QStringList::iterator it = selection.begin(); it!=selection.end(); ++it)
		if(!diffFile(*it))
			return;
}

//------------------------------------------------------------------------------
bool MainWindow::startUI()
{
	bool started = getWorkspace().fossil().startUI("");
	ui->actionFossilUI->setChecked(started);
	return started;
}
//------------------------------------------------------------------------------
void MainWindow::stopUI()
{
	getWorkspace().fossil().stopUI();
	ui->webView->load(QUrl("about:blank"));
	ui->actionFossilUI->setChecked(false);
}

//------------------------------------------------------------------------------
bool MainWindow::uiRunning() const
{
	return getWorkspace().fossil().uiRunning();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionFossilUI_triggered()
{
	if(!uiRunning() && ui->actionFossilUI->isChecked())
	{
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
	// a partial commit which is not permitted.
	QStringList all_modified_files;
	getAllFilenames(all_modified_files, WorkspaceFile::TYPE_MODIFIED);

	if(commit_files.size() != all_modified_files.size())
		files = commit_files;

	if(!fossil().commitFiles(files, msg, branch_name, private_branch))
		QMessageBox::critical(this, tr("Error"), tr("Could not commit changes."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionAdd_triggered()
{
	// Get unknown files only
	QStringList selection;
	getSelectionFilenames(selection, WorkspaceFile::TYPE_UNKNOWN);

	if(selection.empty())
		return;

	if(!FileActionDialog::run(this, tr("Add files"), tr("The following files will be added.")+"\n"+tr("Are you sure?"), selection))
		return;

	// Do Add
	if(!fossil().addFiles(selection))
		QMessageBox::critical(this, tr("Error"), tr("Could not add files."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionDelete_triggered()







|



















|







1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
	// a partial commit which is not permitted.
	QStringList all_modified_files;
	getAllFilenames(all_modified_files, WorkspaceFile::TYPE_MODIFIED);

	if(commit_files.size() != all_modified_files.size())
		files = commit_files;

	if(!getWorkspace().fossil().commitFiles(files, msg, branch_name, private_branch))
		QMessageBox::critical(this, tr("Error"), tr("Could not commit changes."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionAdd_triggered()
{
	// Get unknown files only
	QStringList selection;
	getSelectionFilenames(selection, WorkspaceFile::TYPE_UNKNOWN);

	if(selection.empty())
		return;

	if(!FileActionDialog::run(this, tr("Add files"), tr("The following files will be added.")+"\n"+tr("Are you sure?"), selection))
		return;

	// Do Add
	if(!getWorkspace().fossil().addFiles(selection))
		QMessageBox::critical(this, tr("Error"), tr("Could not add files."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionDelete_triggered()
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652

	if(!FileActionDialog::run(this, tr("Remove files"), tr("The following files will be removed from the repository.")+"\n"+tr("Are you sure?"), all_files, tr("Also delete the local files"), &remove_local ))
		return;

	// Remove repository files
	if(!repo_files.empty())
	{
		if(!fossil().removeFiles(repo_files, remove_local))
			QMessageBox::critical(this, tr("Error"), tr("Could not remove files."), QMessageBox::Ok);
	}

	// Remove unknown local files if selected
	if(remove_local)
	{
		for(int i=0; i<unknown_files.size(); ++i)







|







1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652

	if(!FileActionDialog::run(this, tr("Remove files"), tr("The following files will be removed from the repository.")+"\n"+tr("Are you sure?"), all_files, tr("Also delete the local files"), &remove_local ))
		return;

	// Remove repository files
	if(!repo_files.empty())
	{
		if(!getWorkspace().fossil().removeFiles(repo_files, remove_local))
			QMessageBox::critical(this, tr("Error"), tr("Could not remove files."), QMessageBox::Ok);
	}

	// Remove unknown local files if selected
	if(remove_local)
	{
		for(int i=0; i<unknown_files.size(); ++i)
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
	if(modified_files.empty())
		return;

	if(!FileActionDialog::run(this, tr("Revert files"), tr("The following files will be reverted.")+"\n"+tr("Are you sure?"), modified_files))
		return;

	// Do Revert
	if(!fossil().revertFiles(modified_files))
		QMessageBox::critical(this, tr("Error"), tr("Could not revert files."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionRename_triggered()







|







1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
	if(modified_files.empty())
		return;

	if(!FileActionDialog::run(this, tr("Revert files"), tr("The following files will be reverted.")+"\n"+tr("Are you sure?"), modified_files))
		return;

	// Do Revert
	if(!getWorkspace().fossil().revertFiles(modified_files))
		QMessageBox::critical(this, tr("Error"), tr("Could not revert files."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionRename_triggered()
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
	if(fi_after.exists())
	{
		QMessageBox::critical(this, tr("Error"), tr("File '%0' already exists.\nRename aborted.").arg(new_name), QMessageBox::Ok );
		return;
	}

	// Do Rename
	if(!fossil().renameFile(fi_before.filePath(), fi_after.filePath(), true))
		QMessageBox::critical(this, tr("Error"), tr("Could not rename file '%0' to '%1'").arg(fi_before.filePath(), fi_after.filePath()), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionOpenContaining_triggered()







|







1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
	if(fi_after.exists())
	{
		QMessageBox::critical(this, tr("Error"), tr("File '%0' already exists.\nRename aborted.").arg(new_name), QMessageBox::Ok );
		return;
	}

	// Do Rename
	if(!getWorkspace().fossil().renameFile(fi_before.filePath(), fi_after.filePath(), true))
		QMessageBox::critical(this, tr("Error"), tr("Could not rename file '%0' to '%1'").arg(fi_before.filePath(), fi_after.filePath()), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionOpenContaining_triggered()
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
//------------------------------------------------------------------------------
void MainWindow::on_actionUndo_triggered()
{
	// Gather Undo actions
	QStringList res;

	// Do test Undo
	if(!fossil().undoRepository(res, true))
		QMessageBox::critical(this, tr("Error"), tr("Could not undo changes."), QMessageBox::Ok);

	if(res.length()>0 && res[0]=="No undo or redo is available")
		return;

	if(!FileActionDialog::run(this, tr("Undo"), tr("The following actions will be undone.")+"\n"+tr("Are you sure?"), res))
		return;

	// Do Undo
	if(!fossil().undoRepository(res, false))
		QMessageBox::critical(this, tr("Error"), tr("Could not undo changes."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionAbout_triggered()
{
	QString fossil_ver;
	fossil().getFossilVersion(fossil_ver);

	AboutDialog dlg(this, fossil_ver);
	dlg.exec();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionUpdate_triggered()







|









|









|







1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
//------------------------------------------------------------------------------
void MainWindow::on_actionUndo_triggered()
{
	// Gather Undo actions
	QStringList res;

	// Do test Undo
	if(!getWorkspace().fossil().undoRepository(res, true))
		QMessageBox::critical(this, tr("Error"), tr("Could not undo changes."), QMessageBox::Ok);

	if(res.length()>0 && res[0]=="No undo or redo is available")
		return;

	if(!FileActionDialog::run(this, tr("Undo"), tr("The following actions will be undone.")+"\n"+tr("Are you sure?"), res))
		return;

	// Do Undo
	if(!getWorkspace().fossil().undoRepository(res, false))
		QMessageBox::critical(this, tr("Error"), tr("Could not undo changes."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionAbout_triggered()
{
	QString fossil_ver;
	getWorkspace().fossil().getFossilVersion(fossil_ver);

	AboutDialog dlg(this, fossil_ver);
	dlg.exec();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionUpdate_triggered()
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791

//------------------------------------------------------------------------------
void MainWindow::loadFossilSettings()
{
	// Also retrieve the fossil global settings
	QStringList out;

	if(!fossil().getFossilSettings(out))
		return;

	QStringMap kv;
	ParseProperties(kv, out);

	for(Settings::mappings_t::iterator it=settings.GetMappings().begin(); it!=settings.GetMappings().end(); ++it)
	{







|







1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791

//------------------------------------------------------------------------------
void MainWindow::loadFossilSettings()
{
	// Also retrieve the fossil global settings
	QStringList out;

	if(!getWorkspace().fossil().getFossilSettings(out))
		return;

	QStringMap kv;
	ParseProperties(kv, out);

	for(Settings::mappings_t::iterator it=settings.GetMappings().begin(); it!=settings.GetMappings().end(); ++it)
	{
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
//------------------------------------------------------------------------------
void MainWindow::on_actionSettings_triggered()
{
	// Run the dialog
	if(!SettingsDialog::run(this, settings))
		return;

	fossil().setExecutablePath(settings.GetValue(FUEL_SETTING_FOSSIL_PATH).toString());
	updateCustomActions();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionFossilSettings_triggered()
{
	loadFossilSettings();







|







1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
//------------------------------------------------------------------------------
void MainWindow::on_actionSettings_triggered()
{
	// Run the dialog
	if(!SettingsDialog::run(this, settings))
		return;

	getWorkspace().fossil().setExecutablePath(settings.GetValue(FUEL_SETTING_FOSSIL_PATH).toString());
	updateCustomActions();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionFossilSettings_triggered()
{
	loadFossilSettings();
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
	{
		const QString &name = it.key();
		Settings::Setting::SettingType type = it.value().Type;

		Q_ASSERT(type == Settings::Setting::TYPE_FOSSIL_GLOBAL || type == Settings::Setting::TYPE_FOSSIL_LOCAL);

		QString value = it.value().Value.toString();
		fossil().setFossilSetting(name, value, type == Settings::Setting::TYPE_FOSSIL_GLOBAL);
	}
}

//------------------------------------------------------------------------------
void MainWindow::on_actionViewModified_triggered()
{
	refresh();







|







1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
	{
		const QString &name = it.key();
		Settings::Setting::SettingType type = it.value().Type;

		Q_ASSERT(type == Settings::Setting::TYPE_FOSSIL_GLOBAL || type == Settings::Setting::TYPE_FOSSIL_LOCAL);

		QString value = it.value().Value.toString();
		getWorkspace().fossil().setFossilSetting(name, value, type == Settings::Setting::TYPE_FOSSIL_GLOBAL);
	}
}

//------------------------------------------------------------------------------
void MainWindow::on_actionViewModified_triggered()
{
	refresh();
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
	// Rename files in fossil
	Q_ASSERT(files_to_move.length() == new_paths.length());
	for(int i=0; i<files_to_move.length(); ++i)
	{
		WorkspaceFile *r = files_to_move[i];
		const QString &new_file_path = new_paths[i] + PATH_SEPARATOR + r->getFilename();

		if(!fossil().renameFile(r->getFilePath(), new_file_path, false))
		{
			log(tr("Move aborted due to errors")+"\n");
			goto _exit;
		}
	}

	if(!move_local)







|







2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
	// Rename files in fossil
	Q_ASSERT(files_to_move.length() == new_paths.length());
	for(int i=0; i<files_to_move.length(); ++i)
	{
		WorkspaceFile *r = files_to_move[i];
		const QString &new_file_path = new_paths[i] + PATH_SEPARATOR + r->getFilename();

		if(!getWorkspace().fossil().renameFile(r->getFilePath(), new_file_path, false))
		{
			log(tr("Move aborted due to errors")+"\n");
			goto _exit;
		}
	}

	if(!move_local)
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
		{
			QMessageBox::critical(this, tr("Error"), tr("This stash already exists"));
			return;
		}
	}

	// Do Stash
	if(!fossil().stashNew(stashed_files, stash_name, revert))
		QMessageBox::critical(this, tr("Error"), tr("Could not create stash."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionApplyStash_triggered()







|







2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
		{
			QMessageBox::critical(this, tr("Error"), tr("This stash already exists"));
			return;
		}
	}

	// Do Stash
	if(!getWorkspace().fossil().stashNew(stashed_files, stash_name, revert))
		QMessageBox::critical(this, tr("Error"), tr("Could not create stash."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionApplyStash_triggered()
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

	// Apply stashes
	for(QStringList::iterator it=stashes.begin(); it!=stashes.end(); ++it)
	{
		stashmap_t::iterator id_it = getWorkspace().getStashes().find(*it);
		Q_ASSERT(id_it!=getWorkspace().getStashes().end());

		if(!fossil().stashApply(*id_it))
		{
			log(tr("Stash application aborted due to errors")+"\n");
			QMessageBox::critical(this, tr("Error"), tr("Could not apply stash."), QMessageBox::Ok);
			return;
		}
	}

	// Delete stashes
	for(QStringList::iterator it=stashes.begin(); delete_stashes && it!=stashes.end(); ++it)
	{
		stashmap_t::iterator id_it = getWorkspace().getStashes().find(*it);
		Q_ASSERT(id_it!=getWorkspace().getStashes().end());

		if(!fossil().stashDrop(*id_it))
		{
			log(tr("Stash deletion aborted due to errors")+"\n");
			QMessageBox::critical(this, tr("Error"), tr("Could not delete stash."), QMessageBox::Ok);
			return;
		}
	}








|













|







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

	// Apply stashes
	for(QStringList::iterator it=stashes.begin(); it!=stashes.end(); ++it)
	{
		stashmap_t::iterator id_it = getWorkspace().getStashes().find(*it);
		Q_ASSERT(id_it!=getWorkspace().getStashes().end());

		if(!getWorkspace().fossil().stashApply(*id_it))
		{
			log(tr("Stash application aborted due to errors")+"\n");
			QMessageBox::critical(this, tr("Error"), tr("Could not apply stash."), QMessageBox::Ok);
			return;
		}
	}

	// Delete stashes
	for(QStringList::iterator it=stashes.begin(); delete_stashes && it!=stashes.end(); ++it)
	{
		stashmap_t::iterator id_it = getWorkspace().getStashes().find(*it);
		Q_ASSERT(id_it!=getWorkspace().getStashes().end());

		if(!getWorkspace().fossil().stashDrop(*id_it))
		{
			log(tr("Stash deletion aborted due to errors")+"\n");
			QMessageBox::critical(this, tr("Error"), tr("Could not delete stash."), QMessageBox::Ok);
			return;
		}
	}

2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282

	// Delete stashes
	for(QStringList::iterator it=stashes.begin(); it!=stashes.end(); ++it)
	{
		stashmap_t::iterator id_it = getWorkspace().getStashes().find(*it);
		Q_ASSERT(id_it!=getWorkspace().getStashes().end());

		if(!fossil().stashDrop(*id_it))
		{
			log(tr("Stash deletion aborted due to errors")+"\n");
			QMessageBox::critical(this, tr("Error"), tr("Could not delete stash."), QMessageBox::Ok);
			return;
		}
	}








|







2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282

	// Delete stashes
	for(QStringList::iterator it=stashes.begin(); it!=stashes.end(); ++it)
	{
		stashmap_t::iterator id_it = getWorkspace().getStashes().find(*it);
		Q_ASSERT(id_it!=getWorkspace().getStashes().end());

		if(!getWorkspace().fossil().stashDrop(*id_it))
		{
			log(tr("Stash deletion aborted due to errors")+"\n");
			QMessageBox::critical(this, tr("Error"), tr("Could not delete stash."), QMessageBox::Ok);
			return;
		}
	}

2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
	if(stashes.length() != 1)
		return;

	stashmap_t::iterator id_it = getWorkspace().getStashes().find(*stashes.begin());
	Q_ASSERT(id_it!=getWorkspace().getStashes().end());

	// Run diff
	if(!fossil().stashDiff(*id_it))
		QMessageBox::critical(this, tr("Error"), tr("Could not diff stash."), QMessageBox::Ok);
}

//------------------------------------------------------------------------------
void MainWindow::onFileViewDragOut()
{
	QStringList filenames;







|







2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
	if(stashes.length() != 1)
		return;

	stashmap_t::iterator id_it = getWorkspace().getStashes().find(*stashes.begin());
	Q_ASSERT(id_it!=getWorkspace().getStashes().end());

	// Run diff
	if(!getWorkspace().fossil().stashDiff(*id_it))
		QMessageBox::critical(this, tr("Error"), tr("Could not diff stash."), QMessageBox::Ok);
}

//------------------------------------------------------------------------------
void MainWindow::onFileViewDragOut()
{
	QStringList filenames;
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
		// Any files to add?
		if(!newfiles.empty())
		{
			if(!FileActionDialog::run(this, tr("Add files"), tr("The following files will be added.")+"\n"+tr("Are you sure?"), newfiles))
				return;

			// Do Add
			if(!fossil().addFiles(newfiles))
				QMessageBox::critical(this, tr("Error"), tr("Could not add files."), QMessageBox::Ok);

			refresh();
		}
	}
}








|







2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
		// Any files to add?
		if(!newfiles.empty())
		{
			if(!FileActionDialog::run(this, tr("Add files"), tr("The following files will be added.")+"\n"+tr("Are you sure?"), newfiles))
				return;

			// Do Add
			if(!getWorkspace().fossil().addFiles(newfiles))
				QMessageBox::critical(this, tr("Error"), tr("Could not add files."), QMessageBox::Ok);

			refresh();
		}
	}
}

2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
	ui->centralWidget->setEnabled(enabled);
}

//------------------------------------------------------------------------------
void MainWindow::onAbort()
{
	operationAborted = true;
	fossil().abortOperation();
	// FIXME: Rename this to something better, Operation Aborted
	log("<br><b>* "+tr("Terminated")+" *</b><br>", true);
}

//------------------------------------------------------------------------------
void MainWindow::fullRefresh()
{







|







2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
	ui->centralWidget->setEnabled(enabled);
}

//------------------------------------------------------------------------------
void MainWindow::onAbort()
{
	operationAborted = true;
	getWorkspace().fossil().abortOperation();
	// FIXME: Rename this to something better, Operation Aborted
	log("<br><b>* "+tr("Terminated")+" *</b><br>", true);
}

//------------------------------------------------------------------------------
void MainWindow::fullRefresh()
{
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
		return;
	else if(selected_revision == latest)
		selected_revision = ""; // Empty revision is "latest"

	QStringList res;

	// Do test update
	if(!fossil().updateRepository(res, selected_revision, true))
	{
		QMessageBox::critical(this, tr("Error"), tr("Could not update the repository."), QMessageBox::Ok);
		return;
	}

	if(res.length()==0)
		return;

	QStringMap kv;
	ParseProperties(kv, res, ':');
	// If no changes exit
	if(kv.contains("changes") && kv["changes"].indexOf("None.")!=-1)
		return;

	if(!FileActionDialog::run(this, tr("Update"), tr("The following files will be updated.")+"\n"+tr("Are you sure?"), res))
		return;

	// Do update
	if(!fossil().updateRepository(res, selected_revision, false))
		QMessageBox::critical(this, tr("Error"), tr("Could not update the repository."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionCreateTag_triggered()







|


















|







2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
		return;
	else if(selected_revision == latest)
		selected_revision = ""; // Empty revision is "latest"

	QStringList res;

	// Do test update
	if(!getWorkspace().fossil().updateRepository(res, selected_revision, true))
	{
		QMessageBox::critical(this, tr("Error"), tr("Could not update the repository."), QMessageBox::Ok);
		return;
	}

	if(res.length()==0)
		return;

	QStringMap kv;
	ParseProperties(kv, res, ':');
	// If no changes exit
	if(kv.contains("changes") && kv["changes"].indexOf("None.")!=-1)
		return;

	if(!FileActionDialog::run(this, tr("Update"), tr("The following files will be updated.")+"\n"+tr("Are you sure?"), res))
		return;

	// Do update
	if(!getWorkspace().fossil().updateRepository(res, selected_revision, false))
		QMessageBox::critical(this, tr("Error"), tr("Could not update the repository."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionCreateTag_triggered()
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616

	if(name.isEmpty() || getWorkspace().getTags().contains(name) || getWorkspace().getBranches().contains(name))
	{
		QMessageBox::critical(this, tr("Error"), tr("Invalid name."), QMessageBox::Ok);
		return;
	}

	if(!fossil().tagNew(name, revision))
		QMessageBox::critical(this, tr("Error"), tr("Could not create tag."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionDeleteTag_triggered()
{
	if(selectedTags.size()!=1)
		return;

	const QString &tagname = selectedTags.first();

	if(QMessageBox::Yes != DialogQuery(this, tr("Delete Tag"), tr("Are you sure want to delete the tag '%0' ?").arg(tagname)))
		return;

	Q_ASSERT(getWorkspace().getTags().contains(tagname));

	const QString &revision = getWorkspace().getTags()[tagname];

	if(!fossil().tagDelete(tagname, revision))
		QMessageBox::critical(this, tr("Error"), tr("Could not delete tag."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionCreateBranch_triggered()







|




















|







2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616

	if(name.isEmpty() || getWorkspace().getTags().contains(name) || getWorkspace().getBranches().contains(name))
	{
		QMessageBox::critical(this, tr("Error"), tr("Invalid name."), QMessageBox::Ok);
		return;
	}

	if(!getWorkspace().fossil().tagNew(name, revision))
		QMessageBox::critical(this, tr("Error"), tr("Could not create tag."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionDeleteTag_triggered()
{
	if(selectedTags.size()!=1)
		return;

	const QString &tagname = selectedTags.first();

	if(QMessageBox::Yes != DialogQuery(this, tr("Delete Tag"), tr("Are you sure want to delete the tag '%0' ?").arg(tagname)))
		return;

	Q_ASSERT(getWorkspace().getTags().contains(tagname));

	const QString &revision = getWorkspace().getTags()[tagname];

	if(!getWorkspace().fossil().tagDelete(tagname, revision))
		QMessageBox::critical(this, tr("Error"), tr("Could not delete tag."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionCreateBranch_triggered()
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638

	if(branch_name.isEmpty() || getWorkspace().getTags().contains(branch_name) || getWorkspace().getBranches().contains(branch_name))
	{
		QMessageBox::critical(this, tr("Error"), tr("Invalid name."), QMessageBox::Ok);
		return;
	}

	if(!fossil().branchNew(branch_name, revision, false))
	{
		QMessageBox::critical(this, tr("Error"), tr("Could not create branch."), QMessageBox::Ok);
		return;
	}

	// Update to this branch.
	updateRevision(branch_name);







|







2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638

	if(branch_name.isEmpty() || getWorkspace().getTags().contains(branch_name) || getWorkspace().getBranches().contains(branch_name))
	{
		QMessageBox::critical(this, tr("Error"), tr("Invalid name."), QMessageBox::Ok);
		return;
	}

	if(!getWorkspace().fossil().branchNew(branch_name, revision, false))
	{
		QMessageBox::critical(this, tr("Error"), tr("Could not create branch."), QMessageBox::Ok);
		return;
	}

	// Update to this branch.
	updateRevision(branch_name);
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
	bool force = false;
	revision = RevisionDialog::runMerge(this, tr("Merge Branch"), versionList, revision, integrate, force);

	if(revision.isEmpty())
		return;

	// Do test merge
	if(!fossil().branchMerge(res, revision, integrate, force, true))
	{
		QMessageBox::critical(this, tr("Error"), tr("Merge failed."), QMessageBox::Ok);
		return;
	}

	if(!FileActionDialog::run(this, tr("Merge"), tr("The following changes will be applied.")+"\n"+tr("Are you sure?"), res))
		return;

	// Do update
	if(!fossil().branchMerge(res, revision, integrate, force, false))
		QMessageBox::critical(this, tr("Error"), tr("Merge failed."), QMessageBox::Ok);
	else
		log(tr("Merge completed. Don't forget to commit!")+"\n");

	refresh();
}








|









|







2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
	bool force = false;
	revision = RevisionDialog::runMerge(this, tr("Merge Branch"), versionList, revision, integrate, force);

	if(revision.isEmpty())
		return;

	// Do test merge
	if(!getWorkspace().fossil().branchMerge(res, revision, integrate, force, true))
	{
		QMessageBox::critical(this, tr("Error"), tr("Merge failed."), QMessageBox::Ok);
		return;
	}

	if(!FileActionDialog::run(this, tr("Merge"), tr("The following changes will be applied.")+"\n"+tr("Are you sure?"), res))
		return;

	// Do update
	if(!getWorkspace().fossil().branchMerge(res, revision, integrate, force, false))
		QMessageBox::critical(this, tr("Error"), tr("Merge failed."), QMessageBox::Ok);
	else
		log(tr("Merge completed. Don't forget to commit!")+"\n");

	refresh();
}

2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817

	QUrl url(remotes.first());

	// Retrieve password from keychain
	if(!url.isLocalFile())
		KeychainGet(this, url, *settings.GetStore());

	if(!fossil().pushRepository(url))
		QMessageBox::critical(this, tr("Error"), tr("Could not push to the remote repository."), QMessageBox::Ok);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionPullRemote_triggered()
{
	QStringList remotes;
	getSelectionRemotes(remotes);
	if(remotes.empty())
		return;

	QUrl url(remotes.first());

	// Retrieve password from keychain
	if(!url.isLocalFile())
		KeychainGet(this, url, *settings.GetStore());

	if(!fossil().pullRepository(url))
		QMessageBox::critical(this, tr("Error"), tr("Could not pull from the remote repository."), QMessageBox::Ok);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionPush_triggered()
{
	QUrl url = getWorkspace().getRemoteDefault();

	if(url.isEmpty())
	{
		QMessageBox::critical(this, tr("Error"), tr("A default remote repository has not been specified."), QMessageBox::Ok);
		return;
	}

	// Retrieve password from keychain
	if(!url.isLocalFile())
		KeychainGet(this, url, *settings.GetStore());

	if(!fossil().pushRepository(url))
		QMessageBox::critical(this, tr("Error"), tr("Could not push to the remote repository."), QMessageBox::Ok);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionPull_triggered()
{
	QUrl url = getWorkspace().getRemoteDefault();

	if(url.isEmpty())
	{
		QMessageBox::critical(this, tr("Error"), tr("A default remote repository has not been specified."), QMessageBox::Ok);
		return;
	}

	// Retrieve password from keychain
	if(!url.isLocalFile())
		KeychainGet(this, url, *settings.GetStore());

	if(!fossil().pullRepository(url))
		QMessageBox::critical(this, tr("Error"), tr("Could not pull from the remote repository."), QMessageBox::Ok);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionSetDefaultRemote_triggered()
{
	QStringList remotes;







|

















|


















|


















|







2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817

	QUrl url(remotes.first());

	// Retrieve password from keychain
	if(!url.isLocalFile())
		KeychainGet(this, url, *settings.GetStore());

	if(!getWorkspace().fossil().pushRepository(url))
		QMessageBox::critical(this, tr("Error"), tr("Could not push to the remote repository."), QMessageBox::Ok);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionPullRemote_triggered()
{
	QStringList remotes;
	getSelectionRemotes(remotes);
	if(remotes.empty())
		return;

	QUrl url(remotes.first());

	// Retrieve password from keychain
	if(!url.isLocalFile())
		KeychainGet(this, url, *settings.GetStore());

	if(!getWorkspace().fossil().pullRepository(url))
		QMessageBox::critical(this, tr("Error"), tr("Could not pull from the remote repository."), QMessageBox::Ok);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionPush_triggered()
{
	QUrl url = getWorkspace().getRemoteDefault();

	if(url.isEmpty())
	{
		QMessageBox::critical(this, tr("Error"), tr("A default remote repository has not been specified."), QMessageBox::Ok);
		return;
	}

	// Retrieve password from keychain
	if(!url.isLocalFile())
		KeychainGet(this, url, *settings.GetStore());

	if(!getWorkspace().fossil().pushRepository(url))
		QMessageBox::critical(this, tr("Error"), tr("Could not push to the remote repository."), QMessageBox::Ok);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionPull_triggered()
{
	QUrl url = getWorkspace().getRemoteDefault();

	if(url.isEmpty())
	{
		QMessageBox::critical(this, tr("Error"), tr("A default remote repository has not been specified."), QMessageBox::Ok);
		return;
	}

	// Retrieve password from keychain
	if(!url.isLocalFile())
		KeychainGet(this, url, *settings.GetStore());

	if(!getWorkspace().fossil().pullRepository(url))
		QMessageBox::critical(this, tr("Error"), tr("Could not pull from the remote repository."), QMessageBox::Ok);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionSetDefaultRemote_triggered()
{
	QStringList remotes;
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
			KeychainGet(this, url, *settings.GetStore());

		// FIXME: Fossil currently ignores the password in "remote-url"
		// which breaks commits due to a missing password when autosync is enabled
		// so only set the remote url when there is no password set
		if(url.password().isEmpty())
		{
			if(!fossil().setRemoteUrl(url))
				QMessageBox::critical(this, tr("Error"), tr("Could not set the remote repository."), QMessageBox::Ok);
		}
	}

	updateWorkspaceView();
}








|







2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
			KeychainGet(this, url, *settings.GetStore());

		// FIXME: Fossil currently ignores the password in "remote-url"
		// which breaks commits due to a missing password when autosync is enabled
		// so only set the remote url when there is no password set
		if(url.password().isEmpty())
		{
			if(!getWorkspace().fossil().setRemoteUrl(url))
				QMessageBox::critical(this, tr("Error"), tr("Could not set the remote repository."), QMessageBox::Ok);
		}
	}

	updateWorkspaceView();
}