internal void Remove() { if (ParentBranch != null) { ParentBranch.Remove(this); } else if (ParentContainer != null) { ParentContainer.Content = null; } }
private void OuterDock(DockEventArgs e) { var groups = e.SourceContent.OfType <TabWellModelBase>().ToList(); var newGroup = new ToolWellModel() { Dock = (Dock)((int)e.TargetDock - 5) }; foreach (var group in groups) { var allChildren = group.Children.ToList(); foreach (var item in allChildren) { group.Children.Remove(item); item.IsPinned = false; item.IsActive = false; newGroup.Children.Add(item); } } var newSplit = new SplitPanelModel(); newSplit.Orientation = e.TargetDock == DockTarget.DockLeft || e.TargetDock == DockTarget.DockRight ? Orientation.Horizontal : Orientation.Vertical; if (ParentBranch == null) { ParentContainer.Content = newSplit; } else { ParentBranch.Replace(this, newSplit); } if (e.TargetDock == DockTarget.DockTop || e.TargetDock == DockTarget.DockLeft) { newSplit.Item1 = newGroup; newSplit.Item2 = this; newSplit.Item1.PanelSize = new GridLength(e.DesiredSize); } else { newSplit.Item1 = this; newSplit.Item2 = newGroup; newSplit.Item2.PanelSize = new GridLength(e.DesiredSize); } newGroup.IsActive = true; newGroup.SelectedItem = newGroup.Children.First(); e.SourceWindow.Close(); }
private void OnItemChanged(TabOwnerModelBase prev, TabOwnerModelBase next) { prev?.SetParent(null); next?.SetParent(this); if (next == null) { var remaining = Item1 ?? Item2; if (remaining == null) { return; } Item1 = Item2 = null; if (ParentBranch != null) { ParentBranch.Replace(this, remaining); } else if (ParentContainer != null) { ParentContainer.Content = remaining; } } }
public int Run(string tfsBranchPath, string gitBranchNameExpected) { //[Temporary] Remove in the next version! if (!DontDisplayObsoleteMessage) { _stdout.WriteLine("WARNING: This command is obsolete and will be removed in the next version. Use 'branch --init' instead!"); } var defaultRemote = InitFromDefaultRemote(); // TFS representations of repository paths do not have trailing slashes tfsBranchPath = (tfsBranchPath ?? string.Empty).TrimEnd('/'); var allRemotes = _globals.Repository.ReadAllTfsRemotes(); tfsBranchPath.AssertValidTfsPath(); if (allRemotes.Any(r => r.TfsRepositoryPath.ToLower() == tfsBranchPath.ToLower())) { _stdout.WriteLine("warning : There is already a remote for this tfs branch. Branch ignored!"); return(GitTfsExitCodes.InvalidArguments); } int rootChangeSetId; if (ParentBranch == null) { rootChangeSetId = defaultRemote.Tfs.GetRootChangesetForBranch(tfsBranchPath); } else { var tfsRepositoryPathParentBranchFound = allRemotes.FirstOrDefault(r => r.TfsRepositoryPath.ToLower() == ParentBranch.ToLower()); if (tfsRepositoryPathParentBranchFound == null) { throw new GitTfsException("error: The Tfs parent branch '" + ParentBranch + "' can not be found in the Git repository\nPlease init it first and try again...\n"); } rootChangeSetId = defaultRemote.Tfs.GetRootChangesetForBranch(tfsBranchPath, tfsRepositoryPathParentBranchFound.TfsRepositoryPath); } var sha1RootCommit = _globals.Repository.FindCommitHashByChangesetId(rootChangeSetId); if (string.IsNullOrWhiteSpace(sha1RootCommit)) { throw new GitTfsException("error: The root changeset " + rootChangeSetId + " have not be found in the Git repository. The branch containing the changeset should not have been created. Please do it before retrying!!\n"); } var tfsRemote = CreateBranch(defaultRemote, tfsBranchPath, sha1RootCommit, gitBranchNameExpected); if (!NoFetch) { FetchRemote(tfsRemote, false); } else { Trace.WriteLine("Not fetching changesets, --nofetch option specified"); } return(GitTfsExitCodes.OK); }
private int CloneBranch(string tfsBranchPath, string gitBranchNameExpected) { var defaultRemote = InitFromDefaultRemote(); // TFS representations of repository paths do not have trailing slashes tfsBranchPath = (tfsBranchPath ?? string.Empty).TrimEnd('/'); if (!tfsBranchPath.IsValidTfsPath()) { var remotes = _globals.Repository.GetLastParentTfsCommits(tfsBranchPath); if (!remotes.Any()) { throw new Exception("error: No TFS branch found!"); } tfsBranchPath = remotes.First().Remote.TfsRepositoryPath; } tfsBranchPath.AssertValidTfsPath(); var allRemotes = _globals.Repository.ReadAllTfsRemotes(); var remote = allRemotes.FirstOrDefault(r => r.TfsRepositoryPath.ToLower() == tfsBranchPath.ToLower()); if (remote != null && remote.MaxChangesetId != 0) { _stdout.WriteLine("warning : There is already a remote for this tfs branch. Branch ignored!"); return(GitTfsExitCodes.InvalidArguments); } IList <RootBranch> creationBranchData; if (ParentBranch == null) { creationBranchData = defaultRemote.Tfs.GetRootChangesetForBranch(tfsBranchPath); } else { var tfsRepositoryPathParentBranchFound = allRemotes.FirstOrDefault(r => r.TfsRepositoryPath.ToLower() == ParentBranch.ToLower()); if (tfsRepositoryPathParentBranchFound == null) { throw new GitTfsException("error: The Tfs parent branch '" + ParentBranch + "' can not be found in the Git repository\nPlease init it first and try again...\n"); } creationBranchData = defaultRemote.Tfs.GetRootChangesetForBranch(tfsBranchPath, -1, tfsRepositoryPathParentBranchFound.TfsRepositoryPath); } IFetchResult fetchResult; InitBranchSupportingRename(tfsBranchPath, gitBranchNameExpected, creationBranchData, defaultRemote, out fetchResult); return(GitTfsExitCodes.OK); }
protected override void DockExecuted(DockEventArgs e) { if (e.TargetDock == DockTarget.Center) { base.DockExecuted(e); return; } var groups = e.SourceContent.OfType <TabWellModelBase>().ToList(); var newGroup = new ToolWellModel() { Dock = Dock }; foreach (var group in groups) { var allChildren = group.Children.ToList(); foreach (var item in allChildren) { group.Children.Remove(item); item.IsPinned = false; item.IsActive = false; newGroup.Children.Add(item); } } var newSplit = new SplitPanelModel(); double remainingSize; if (e.TargetDock == DockTarget.SplitLeft || e.TargetDock == DockTarget.SplitRight) { newSplit.Orientation = Orientation.Horizontal; remainingSize = Width - e.DesiredSize; } else { newSplit.Orientation = Orientation.Vertical; remainingSize = Height - e.DesiredSize; } ParentBranch.Replace(this, newSplit); if (e.TargetDock == DockTarget.SplitTop || e.TargetDock == DockTarget.SplitLeft) { newSplit.Item1 = newGroup; newSplit.Item2 = this; newSplit.Item1.PanelSize = new GridLength(e.DesiredSize, GridUnitType.Star); newSplit.Item2.PanelSize = new GridLength(remainingSize, GridUnitType.Star); } else { newSplit.Item1 = this; newSplit.Item2 = newGroup; newSplit.Item1.PanelSize = new GridLength(remainingSize, GridUnitType.Star); newSplit.Item2.PanelSize = new GridLength(e.DesiredSize, GridUnitType.Star); } newGroup.IsActive = true; newGroup.SelectedItem = newGroup.Children.First(); e.SourceWindow.Close(); }
private int CloneBranch(string tfsBranchPath, string gitBranchNameExpected) { var defaultRemote = InitFromDefaultRemote(); // TFS representations of repository paths do not have trailing slashes tfsBranchPath = (tfsBranchPath ?? string.Empty).TrimEnd('/'); if (!tfsBranchPath.IsValidTfsPath()) { var remotes = _globals.Repository.GetLastParentTfsCommits(tfsBranchPath); if (!remotes.Any()) { throw new Exception("error: No TFS branch found!"); } tfsBranchPath = remotes.First().Remote.TfsRepositoryPath; } tfsBranchPath.AssertValidTfsPath(); IFetchResult fetchResult; var allRemotes = _globals.Repository.ReadAllTfsRemotes().ToList(); var remote = allRemotes.FirstOrDefault(r => String.Equals(r.TfsRepositoryPath, tfsBranchPath, StringComparison.OrdinalIgnoreCase)); if (remote != null && remote.MaxChangesetId != 0) { Trace.WriteLine("Fetching remote: " + remote.Id); fetchResult = FetchRemote(remote, true, forceRefUpdate: true); if (fetchResult.NewChangesetCount != 0) { Trace.TraceInformation("Existing branch: fetched new changes."); _globals.Repository.GarbageCollect(); } else { Trace.TraceInformation("Existing branch: no new changes found."); } return(GitTfsExitCodes.OK); } IList <RootBranch> creationBranchData; if (ParentBranch == null) { creationBranchData = defaultRemote.Tfs.GetRootChangesetForBranch(tfsBranchPath); } else { var tfsRepositoryPathParentBranchFound = allRemotes.FirstOrDefault(r => r.TfsRepositoryPath.ToLower() == ParentBranch.ToLower()); if (tfsRepositoryPathParentBranchFound == null) { throw new GitTfsException("error: The Tfs parent branch '" + ParentBranch + "' can not be found in the Git repository\nPlease init it first and try again...\n"); } creationBranchData = defaultRemote.Tfs.GetRootChangesetForBranch(tfsBranchPath, -1, tfsRepositoryPathParentBranchFound.TfsRepositoryPath); } InitBranchSupportingRename(tfsBranchPath, gitBranchNameExpected, creationBranchData, defaultRemote, out fetchResult); return(GitTfsExitCodes.OK); }