Fuel

Diff
Login

Differences From Artifact [d5adcea39c]:

To Artifact [4268a41085]:


318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
	ui->mainToolBar->addWidget(spacer);

	viewMode = VIEWMODE_TREE;

	uiCallback.init(this);

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

	applySettings();

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








|







318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
	ui->mainToolBar->addWidget(spacer);

	viewMode = VIEWMODE_TREE;

	uiCallback.init(this);

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

	applySettings();

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

401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
							wkspace);

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

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

		}
		else







|







401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
							wkspace);

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

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

		}
		else
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
547
548
549
550

	stopUI();
	on_actionClearLog_triggered();

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

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

	if(!getWorkspace().fossil().createWorkspace(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().getWorkspaceState()!=Fossil::WORKSPACE_STATE_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().closeWorkspace())
	{
		QMessageBox::critical(this, tr("Error"), tr("Cannot close the workspace.\nAre there still uncommitted changes available?"), QMessageBox::Ok );
		return;
	}

	stopUI();
	setCurrentWorkspace("");







|





|















|






|







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
547
548
549
550

	stopUI();
	on_actionClearLog_triggered();

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

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

	if(!getWorkspace().createWorkspace(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().getWorkspaceState()!=Fossil::WORKSPACE_STATE_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().closeWorkspace())
	{
		QMessageBox::critical(this, tr("Error"), tr("Cannot close the workspace.\nAre there still uncommitted changes available?"), QMessageBox::Ok );
		return;
	}

	stopUI();
	setCurrentWorkspace("");
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
	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;







|







558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
	QString repository;

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

	stopUI();

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

	if(!openWorkspace(repository))
		return;
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
//------------------------------------------------------------------------------
bool MainWindow::scanWorkspace()
{
	setBusy(true);
	bool valid = true;

	// Load repository info
	Fossil::WorkspaceState st = getWorkspace().fossil().getWorkspaceState();
	QString status;

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







|







689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
//------------------------------------------------------------------------------
bool MainWindow::scanWorkspace()
{
	setBusy(true);
	bool valid = true;

	// Load repository info
	Fossil::WorkspaceState st = getWorkspace().getWorkspaceState();
	QString status;

	if(st==Fossil::WORKSPACE_STATE_NOTFOUND)
	{
		status = tr("No workspace detected.");
		valid = false;
	}
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
	}
}
//------------------------------------------------------------------------------
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);







|

|







1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
	}
}
//------------------------------------------------------------------------------
bool MainWindow::diffFile(const QString &repoFile)
{
	const QString &gdiff = settings.GetFossilValue(FOSSIL_SETTING_GDIFF_CMD).toString();
	if(!gdiff.isEmpty())
		return getWorkspace().diffFile(repoFile, true);
	else
		return getWorkspace().diffFile(repoFile, false);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionDiff_triggered()
{
	QStringList selection;
	getSelectionFilenames(selection, WorkspaceFile::TYPE_REPO);
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
1625
1626
1627
	// 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()







|



















|







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
1625
1626
1627
	// 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().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().addFiles(selection))
		QMessageBox::critical(this, tr("Error"), tr("Could not add files."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionDelete_triggered()
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655

	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)







|







1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655

	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().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)
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
	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()







|







1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
	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().revertFiles(modified_files))
		QMessageBox::critical(this, tr("Error"), tr("Could not revert files."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionRename_triggered()
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
	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()







|







1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
	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().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()
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
1768
1769
1770
1771
1772
//------------------------------------------------------------------------------
void MainWindow::on_actionUndo_triggered()
{
	// Gather Undo actions
	QStringList res;

	// Do test Undo
	if(!getWorkspace().fossil().undoWorkspace(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().undoWorkspace(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().getExeVersion(fossil_ver);

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

//------------------------------------------------------------------------------
void MainWindow::on_actionUpdate_triggered()
{
	QStringList selected = selectedBranches + selectedTags;







|









|








|
|

|







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
1768
1769
1770
1771
1772
//------------------------------------------------------------------------------
void MainWindow::on_actionUndo_triggered()
{
	// Gather Undo actions
	QStringList res;

	// Do test Undo
	if(!getWorkspace().undoWorkspace(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().undoWorkspace(res, false))
		QMessageBox::critical(this, tr("Error"), tr("Could not undo changes."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionAbout_triggered()
{
	QString version;
	getWorkspace().getInterfaceVersion(version);

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

//------------------------------------------------------------------------------
void MainWindow::on_actionUpdate_triggered()
{
	QStringList selected = selectedBranches + selectedTags;
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
	// 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)







|







2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
	// 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().renameFile(r->getFilePath(), new_file_path, false))
		{
			log(tr("Move aborted due to errors")+"\n");
			goto _exit;
		}
	}

	if(!move_local)
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
		{
			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()







|







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

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

	refresh();
}

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

	// 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;
		}
	}








|













|







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

	// 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().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().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;
		}
	}

2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285

	// 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;
		}
	}








|







2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285

	// 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().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;
		}
	}

2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
	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;







|







2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
	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().stashDiff(*id_it))
		QMessageBox::critical(this, tr("Error"), tr("Could not diff stash."), QMessageBox::Ok);
}

//------------------------------------------------------------------------------
void MainWindow::onFileViewDragOut()
{
	QStringList filenames;
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
		// 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();
		}
	}
}








|







2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
		// 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().addFiles(newfiles))
				QMessageBox::critical(this, tr("Error"), tr("Could not add files."), QMessageBox::Ok);

			refresh();
		}
	}
}

2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
		return;
	else if(selected_revision == latest)
		selected_revision = ""; // Empty revision is "latest"

	QStringList res;

	// Do test update
	if(!getWorkspace().fossil().updateWorkspace(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().updateWorkspace(res, selected_revision, false))
		QMessageBox::critical(this, tr("Error"), tr("Could not update the repository."), QMessageBox::Ok);

	refresh();
}

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







|



















|







2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
		return;
	else if(selected_revision == latest)
		selected_revision = ""; // Empty revision is "latest"

	QStringList res;

	// Do test update
	if(!getWorkspace().updateWorkspace(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().updateWorkspace(res, selected_revision, false))
		QMessageBox::critical(this, tr("Error"), tr("Could not update the repository."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionCreateTag_triggered()
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641

	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()







|




















|







2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641

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

	if(!getWorkspace().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().tagDelete(tagname, revision))
		QMessageBox::critical(this, tr("Error"), tr("Could not delete tag."), QMessageBox::Ok);

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionCreateBranch_triggered()
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663

	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);







|







2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663

	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().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);
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
	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();
}








|









|







2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
	bool force = false;
	revision = RevisionDialog::runMerge(this, tr("Merge Branch"), versionList, revision, integrate, force);

	if(revision.isEmpty())
		return;

	// Do test merge
	if(!getWorkspace().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().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();
}

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
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842

	QUrl url(remotes.first());

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

	if(!getWorkspace().fossil().pushWorkspace(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().pullWorkspace(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().pushWorkspace(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().pullWorkspace(url))
		QMessageBox::critical(this, tr("Error"), tr("Could not pull from the remote repository."), QMessageBox::Ok);
}

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







|

















|


















|


















|







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
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842

	QUrl url(remotes.first());

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

	if(!getWorkspace().pushWorkspace(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().pullWorkspace(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().pushWorkspace(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().pullWorkspace(url))
		QMessageBox::critical(this, tr("Error"), tr("Could not pull from the remote repository."), QMessageBox::Ok);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionSetDefaultRemote_triggered()
{
	QStringList remotes;
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
			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();
}








|







2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
			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().setDefaultRemoteUrl(url))
				QMessageBox::critical(this, tr("Error"), tr("Could not set the remote repository."), QMessageBox::Ok);
		}
	}

	updateWorkspaceView();
}