Initial work on branching during commit
Refactored CommitDialog usage FossilOrigin-Name: 4b4c7cdb6d717d381081bbfbd7e9657acf32d089
This commit is contained in:
@@ -109,6 +109,19 @@ bool CommitDialog::run(QWidget *parent, const QString &title, QStringList &files
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool CommitDialog::runCommit(QWidget* parent, QStringList& files, QString& commitMsg, const QStringList& commitMsgHistory)
|
||||
{
|
||||
return run(parent, tr("Commit Changes"), files, commitMsg, &commitMsgHistory, false, 0, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool CommitDialog::runStashNew(QWidget* parent, QStringList& stashedFiles, QString& stashName, bool& checkBoxValue)
|
||||
{
|
||||
QString checkbox_text = tr("Revert stashed files");
|
||||
return run(parent, tr("Stash Changes"), stashedFiles, stashName, 0, true, &checkbox_text, &checkBoxValue);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void CommitDialog::on_comboBox_activated(int index)
|
||||
{
|
||||
|
@@ -16,7 +16,11 @@ public:
|
||||
explicit CommitDialog(QWidget *parent, const QString &title, QStringList &files, const QStringList *history=0, bool singleLineEntry=false, const QString *checkBoxText=0, bool *checkBoxValue=0);
|
||||
~CommitDialog();
|
||||
|
||||
static bool run(QWidget *parent, const QString &title, QStringList &files, QString &commitMsg, const QStringList *history=0, bool singleLineEntry=false, const QString *checkBoxText=0, bool *checkBoxValue=0);
|
||||
static bool runStashNew(QWidget* parent, QStringList& stashedFiles, QString& stashName, bool &checkBoxValue);
|
||||
static bool runCommit(QWidget* parent, QStringList& files, QString& commitMsg, const QStringList &commitMsgHistory);
|
||||
|
||||
private:
|
||||
static bool run(QWidget *parent, const QString &title, QStringList &files, QString &commitMsg, const QStringList *history, bool singleLineEntry, const QString *checkBoxText, bool *checkBoxValue);
|
||||
|
||||
private slots:
|
||||
void on_comboBox_activated(int index);
|
||||
|
@@ -197,7 +197,7 @@ bool Fossil::diffFile(const QString &repoFile)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Fossil::commitFiles(const QStringList& fileList, const QString& comment)
|
||||
bool Fossil::commitFiles(const QStringList& fileList, const QString& comment, const QString &newBranchName, bool isPrivateBranch)
|
||||
{
|
||||
// Do commit
|
||||
QString comment_fname;
|
||||
@@ -223,6 +223,17 @@ bool Fossil::commitFiles(const QStringList& fileList, const QString& comment)
|
||||
// Generate fossil parameters.
|
||||
QStringList params;
|
||||
params << "commit" << "--message-file" << QuotePath(comment_fname);
|
||||
|
||||
// Commit to new branch
|
||||
if(!newBranchName.isEmpty())
|
||||
{
|
||||
params << "--branch" << newBranchName;
|
||||
|
||||
// Private branches are not synced with remotes
|
||||
if(isPrivateBranch)
|
||||
params << "--private";
|
||||
}
|
||||
|
||||
params << QuotePaths(fileList);
|
||||
|
||||
runFossil(params);
|
||||
|
@@ -96,7 +96,7 @@ public:
|
||||
bool status(QStringList& result);
|
||||
|
||||
bool diffFile(const QString &repoFile);
|
||||
bool commitFiles(const QStringList &fileList, const QString &comment);
|
||||
bool commitFiles(const QStringList &fileList, const QString &comment, const QString& newBranchName, bool isPrivateBranch);
|
||||
bool addFiles(const QStringList& fileList);
|
||||
bool removeFiles(const QStringList& fileList, bool deleteLocal);
|
||||
bool revertFiles(const QStringList& fileList);
|
||||
|
@@ -1358,7 +1358,7 @@ void MainWindow::on_actionCommit_triggered()
|
||||
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);
|
||||
bool aborted = !CommitDialog::runCommit(this, commit_files, msg, commit_msgs);
|
||||
|
||||
// Aborted or not we always keep the commit messages.
|
||||
// (This has saved me way too many times on TortoiseSVN)
|
||||
@@ -1388,7 +1388,11 @@ void MainWindow::on_actionCommit_triggered()
|
||||
if(commit_files.size() != all_modified_files.size())
|
||||
files = commit_files;
|
||||
|
||||
fossil().commitFiles(files, msg);
|
||||
// FIXME: add UI
|
||||
QString branch_name="";
|
||||
bool private_branch = false;
|
||||
|
||||
fossil().commitFiles(files, msg, branch_name, private_branch);
|
||||
refresh();
|
||||
}
|
||||
|
||||
@@ -1960,8 +1964,8 @@ void MainWindow::on_actionNewStash_triggered()
|
||||
|
||||
QString stash_name;
|
||||
bool revert = false;
|
||||
QString checkbox_text = tr("Revert stashed files");
|
||||
if(!CommitDialog::run(this, tr("Stash Changes"), stashed_files, stash_name, 0, true, &checkbox_text, &revert) || stashed_files.empty())
|
||||
|
||||
if(!CommitDialog::runStashNew(this, stashed_files, stash_name, revert) || stashed_files.empty())
|
||||
return;
|
||||
|
||||
stash_name = stash_name.trimmed();
|
||||
|
Reference in New Issue
Block a user