Skip to content

Commit

Permalink
Merge pull request #1674 from feinstaub/topic_1575_remove_old_branch_dlg
Browse files Browse the repository at this point in the history
Fixes #1575 (Remove old "Create branch" dialog)
  • Loading branch information
KindDragon committed Mar 1, 2013
2 parents 74ffa5c + 7c49bdf commit 655a4e1
Show file tree
Hide file tree
Showing 19 changed files with 461 additions and 444 deletions.
4 changes: 2 additions & 2 deletions GitUI/CommandsDialogs/FormArchive.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion GitUI/CommandsDialogs/FormBrowse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,7 @@ private void GitTreeBeforeExpand(object sender, TreeViewCancelEventArgs e)

private void CreateBranchToolStripMenuItemClick(object sender, EventArgs e)
{
UICommands.StartCreateBranchDialog(this);
UICommands.StartCreateBranchDialog(this, RevisionGrid.GetSelectedRevisions().FirstOrDefault());
}

private void RevisionGridDoubleClick(object sender, EventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions GitUI/CommandsDialogs/FormCherryPick.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

325 changes: 219 additions & 106 deletions GitUI/CommandsDialogs/FormCreateBranch.Designer.cs

Large diffs are not rendered by default.

105 changes: 72 additions & 33 deletions GitUI/CommandsDialogs/FormCreateBranch.cs
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;
}
}
}
}
}
3 changes: 3 additions & 0 deletions GitUI/CommandsDialogs/FormCreateBranch.resx
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
4 changes: 2 additions & 2 deletions GitUI/CommandsDialogs/FormRevertCommit.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion GitUI/CommandsDialogs/FormVerify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private void mnuLostObjectsCreateTag_Click(object sender, EventArgs e)

private void mnuLostObjectsCreateBranch_Click(object sender, EventArgs e)
{
using (var frm = new FormCreateBranchAtRevision(UICommands) { Revision = GetCurrentGitRevision() })
using (var frm = new FormCreateBranch(UICommands) { Revision = GetCurrentGitRevision() })
{
var dialogResult = frm.ShowDialog(this);
if (dialogResult == DialogResult.OK)
Expand Down
25 changes: 12 additions & 13 deletions GitUI/GitUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,16 @@
<DependentUpon>BranchComboBox.cs</DependentUpon>
</Compile>
<Compile Include="CommitInfo\CommandEventArgs.cs" />
<Compile Include="CommitInfo\CommitSummaryUserControl.cs">
<Compile Include="UserControls\CommitPickerSmallControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="CommitInfo\CommitSummaryUserControl.Designer.cs">
<Compile Include="UserControls\CommitPickerSmallControl.Designer.cs">
<DependentUpon>CommitPickerSmallControl.cs</DependentUpon>
</Compile>
<Compile Include="UserControls\CommitSummaryUserControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UserControls\CommitSummaryUserControl.Designer.cs">
<DependentUpon>CommitSummaryUserControl.cs</DependentUpon>
</Compile>
<Compile Include="CommandsDialogs\CommitDialog\CommitTemplateItem.cs" />
Expand Down Expand Up @@ -572,12 +578,6 @@
<Compile Include="CommandsDialogs\FormCreateBranch.Designer.cs">
<DependentUpon>FormCreateBranch.cs</DependentUpon>
</Compile>
<Compile Include="HelperDialogs\FormCreateBranchAtRevision.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="HelperDialogs\FormCreateBranchAtRevision.Designer.cs">
<DependentUpon>FormCreateBranchAtRevision.cs</DependentUpon>
</Compile>
<Compile Include="CommandsDialogs\BrowseDialog\FormChangeLog.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -892,7 +892,10 @@
<DependentUpon>ViewPullRequestsForm.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="CommitInfo\CommitSummaryUserControl.resx">
<EmbeddedResource Include="UserControls\CommitPickerSmallControl.resx">
<DependentUpon>CommitPickerSmallControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UserControls\CommitSummaryUserControl.resx">
<DependentUpon>CommitSummaryUserControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Editor\FormGoToLine.resx">
Expand Down Expand Up @@ -1108,10 +1111,6 @@
<DependentUpon>FormCreateBranch.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="HelperDialogs\FormCreateBranchAtRevision.resx">
<DependentUpon>FormCreateBranchAtRevision.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="CommandsDialogs\BrowseDialog\FormChangeLog.resx">
<DependentUpon>FormChangeLog.cs</DependentUpon>
<SubType>Designer</SubType>
Expand Down
13 changes: 8 additions & 5 deletions GitUI/GitUICommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using GitUIPluginInterfaces.RepositoryHosts;
using Gravatar;
using Settings = GitCommands.Settings;
using GitUI.HelperDialogs;

namespace GitUI
{
Expand Down Expand Up @@ -489,21 +490,23 @@ public bool StartAddFilesDialog()
return StartAddFilesDialog(null, null);
}

public bool StartCreateBranchDialog(IWin32Window owner)
public bool StartCreateBranchDialog(IWin32Window owner, GitRevision revision)
{
Func<bool> action = () =>
{
using (var form = new FormCreateBranch(this))
form.ShowDialog(owner);
return true;
{
form.Revision = revision;
return form.ShowDialog(owner) == DialogResult.OK;
}
};

return DoActionOnRepo(owner, true, false, PreCreateBranch, PostCreateBranch, action);
return DoActionOnRepo(owner, true, true, PreCreateBranch, PostCreateBranch, action);
}

public bool StartCreateBranchDialog()
{
return StartCreateBranchDialog(null);
return StartCreateBranchDialog(null, null);
}

public bool StartCloneDialog(IWin32Window owner, string url, bool openedFromProtocolHandler, GitModuleChangedEventHandler GitModuleChanged)
Expand Down

0 comments on commit 655a4e1

Please sign in to comment.