-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1674 from feinstaub/topic_1575_remove_old_branch_dlg
Fixes #1575 (Remove old "Create branch" dialog)
- Loading branch information
Showing
19 changed files
with
461 additions
and
444 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,105 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.Windows.Forms; | ||
using GitCommands; | ||
using ResourceManager.Translation; | ||
|
||
namespace GitUI.CommandsDialogs | ||
{ | ||
public partial class FormCreateBranch : GitModuleForm | ||
public sealed partial class FormCreateBranch : GitModuleForm | ||
{ | ||
private readonly TranslationString _selectOneRevision = new TranslationString("Select 1 revision to create the branch on."); | ||
private readonly TranslationString _branchCaption = new TranslationString("Branch"); | ||
private readonly TranslationString _noRevisionSelected = | ||
new TranslationString("Select 1 revision to create the branch on."); | ||
private readonly TranslationString _branchNameIsEmpty = | ||
new TranslationString("Enter branch name."); | ||
private readonly TranslationString _branchNameIsNotValud = | ||
new TranslationString("“{0}” is not valid branch name."); | ||
|
||
/// <summary> | ||
/// For VS designer | ||
/// </summary> | ||
private FormCreateBranch() | ||
: this(null) | ||
public FormCreateBranch(GitUICommands aCommands) | ||
: base(aCommands) | ||
{ | ||
InitializeComponent(); | ||
Translate(); | ||
|
||
commitPickerSmallControl1.UICommandsSource = this; | ||
} | ||
|
||
GitRevision _revision; | ||
public GitRevision Revision | ||
{ | ||
get { return _revision; } | ||
set | ||
{ | ||
_revision = value; | ||
commitPickerSmallControl1.SelectedCommitHash = _revision.Guid; | ||
} | ||
} | ||
|
||
public FormCreateBranch(GitUICommands aCommands) | ||
: base(true, aCommands) | ||
private void FormCreateBranchAtRevision_Load(object sender, EventArgs e) | ||
{ | ||
InitializeComponent(); | ||
Translate(); | ||
BranchNameTextBox.Focus(); | ||
} | ||
|
||
private void Ok_Click(object sender, EventArgs e) | ||
private void OkClick(object sender, EventArgs e) | ||
{ | ||
string commitGuid = commitPickerSmallControl1.SelectedCommitHash; | ||
var branchName = BranchNameTextBox.Text.Trim(); | ||
|
||
if (branchName.IsNullOrWhiteSpace()) | ||
{ | ||
MessageBox.Show(_branchNameIsEmpty.Text, Text); | ||
DialogResult = DialogResult.None; | ||
return; | ||
} | ||
if (!Module.CheckBranchFormat(branchName)) | ||
{ | ||
MessageBox.Show(string.Format(_branchNameIsNotValud.Text, branchName), Text); | ||
DialogResult = DialogResult.None; | ||
return; | ||
} | ||
try | ||
{ | ||
|
||
if (RevisionGrid.GetSelectedRevisions().Count != 1) | ||
if (commitGuid == null) | ||
{ | ||
MessageBox.Show(this, _selectOneRevision.Text, _branchCaption.Text); | ||
MessageBox.Show(this, _noRevisionSelected.Text, Text); | ||
return; | ||
} | ||
|
||
string cmd = GitCommandHelpers.BranchCmd(BName.Text, RevisionGrid.GetSelectedRevisions()[0].Guid, CheckoutAfterCreate.Checked); | ||
FormProcess.ShowDialog(this, cmd); | ||
UICommands.RepoChangedNotifier.Notify(); | ||
string cmd; | ||
if (Orphan.Checked) | ||
{ | ||
cmd = GitCommandHelpers.CreateOrphanCmd(branchName, commitGuid); | ||
} | ||
else | ||
{ | ||
cmd = GitCommandHelpers.BranchCmd(branchName, commitGuid, CheckoutAfterCreate.Checked); | ||
} | ||
|
||
Close(); | ||
bool wasSuccessFul = FormProcess.ShowDialog(this, cmd); | ||
if (Orphan.Checked && wasSuccessFul && ClearOrphan.Checked) | ||
{// orphan AND orphan creation success AND clear | ||
cmd = GitCommandHelpers.RemoveCmd(); | ||
FormProcess.ShowDialog(this, cmd); | ||
} | ||
|
||
DialogResult = DialogResult.OK; | ||
} | ||
catch | ||
catch (Exception ex) | ||
{ | ||
Trace.WriteLine(ex.Message); | ||
} | ||
} | ||
|
||
private void Checkout_Click(object sender, EventArgs e) | ||
{ | ||
UICommands.StartCheckoutBranchDialog(this); | ||
RevisionGrid.RefreshRevisions(); | ||
} | ||
|
||
private void FormBranch_Load(object sender, EventArgs e) | ||
void Orphan_CheckedChanged(object sender, EventArgs e) | ||
{ | ||
RevisionGrid.Load(); | ||
|
||
BName.Focus(); | ||
AcceptButton = Ok; | ||
bool isOrphan = Orphan.Checked; | ||
ClearOrphan.Enabled = isOrphan; | ||
|
||
CheckoutAfterCreate.Enabled = (isOrphan == false);// auto-checkout for orphan | ||
if (isOrphan) | ||
{ | ||
CheckoutAfterCreate.Checked = true; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.