public CommitVertex(string sha, string message) { Sha = sha; Message = message; Branches = new BranchCollection(); Branches.CollectionChanged += (o, e) => RaisePropertyChanged(() => HasBranches); }
public void AddsBranchToCollection() { var branches = new BranchCollection(); branches.Merge(new SeeGit.BranchReference {Name = "foo"}); Assert.Equal(1, branches.Count); }
public void RefreshDisplay() { _lookup = Branch.CollectAll(); _viewModel = new BranchViewModel { Collection = Branch.CollectAll() }; DataContext = _viewModel; }
public InternalNode(Branch branch, BranchCollection branches, bool isModified) : base(branch) { Debug.Assert(branch.NodeType == NodeType.Internal); Branches = branches; IsModified = isModified; }
public InternalNode(Branch branch, BranchCollection branches, bool isModified) : base(branch) { Debug.Assert(branch.NodeType == NodeType.Internal); Branches = branches; IsModified = isModified; }
public void AddsBranchToCollection() { var branches = new BranchCollection(); branches.Merge(new SeeGit.BranchReference { Name = "foo" }); Assert.Equal(1, branches.Count); }
public void MergesBranchWithSameNameAsExistingGivingPrecedenceToNewerOne() { var branches = new BranchCollection(); branches.Merge(new SeeGit.BranchReference {Name = "foo", IsCurrent = false, IsHead = true, IsRemote = true}); branches.Merge(new SeeGit.BranchReference {Name = "foo", IsCurrent = true, IsRemote = true, IsHead = true}); Assert.Equal(1, branches.Count); Assert.True(branches.First().IsCurrent); }
public void AddsBranchToCollection() { var branches = new BranchCollection(); branches.Merge(new SeeGit.BranchReference { Name = "foo" }); Assert.Single(branches); }
private void ClearFilters() { SelectedRepositories = new List <string>(); this.SelectedRepositoriesItemChanged.Execute(this); BranchSelectedItem = BranchCollection.FirstOrDefault() ?? string.Empty; SelectedAuthors = new List <string>(); this.SelectedAuthorsItemChanged.Execute(this); MessageTextBox = String.Empty; FromDate = String.Empty; ToDate = String.Empty; }
public CommitVertex(string sha, string message) { Sha = sha; Message = message; Branches = new BranchCollection(); Branches.CollectionChanged += (o, e) => RaisePropertyChanged(() => HasBranches); ShaLength = MainWindow.Configuration.GetSetting("SHALength", 8); DescriptionShown = MainWindow.Configuration.GetSetting("DescriptionInExpander", false); AdornerMessageVisibilityType = MainWindow.Configuration.GetSetting("AdornerCommitMessageVisibility", "ExpandedHidden"); Expanded = false; }
internal static BranchCollection CollectAll() { var dataTable = DatabaseController.ExecuteSelectQuery("SELECT * FROM " + TABLE_NAME); var collection = new BranchCollection(); foreach (DataRow dataRow in dataTable.Rows) { var item = new Branch(); item.SetPropertiesFromDataRow(dataRow); collection.Add(item); } return(collection); }
public void MergesBranchWithSameNameAsExistingGivingPrecedenceToNewerOne() { var branches = new BranchCollection(); branches.Merge(new SeeGit.BranchReference { Name = "foo", IsCurrent = false, IsHead = true, IsRemote = true }); branches.Merge(new SeeGit.BranchReference { Name = "foo", IsCurrent = true, IsRemote = true, IsHead = true }); Assert.Equal(1, branches.Count); Assert.True(branches.First().IsCurrent); }
public static BranchCollection Search(SearchFilter SearchKey) { BranchCollection collection = new BranchCollection(); using (var reader = SqlHelper.ExecuteReader("Branch_Search", SearchFilterManager.SqlSearchParam(SearchKey))) { while (reader.Read()) { Branch obj = new Branch(); obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }
public List <Tuple <Commit, int> > ComputeRows(IEnumerable <Commit> c, BranchCollection b) { if (!c.Any()) { return(Result); } List <Node> nodes = Nodes(c); Add(nodes.First()); HashSet <Commit> branches = new HashSet <Commit>(b.Select(branch => branch.Tip)); IEnumerable <Node> branchTips = nodes.Where(node => branches.Contains(node.Commit)).ToList(); foreach (Node n in nodes.Skip(1)) { List <Node> possibleDescOnSameRow = n.Descendants.Where(d => !d.HasPredecessorOnSameRow && ( d.Predecessors.Count == 1 || d.Predecessors.Count - 1 == d.DeployedPredecessors)).ToList(); List <int> complement = n.Descendants.Except(possibleDescOnSameRow).Select(x => x.Row).ToList(); possibleDescOnSameRow.RemoveAll(d => complement.Contains(d.Row)); List <Node> sortedDescendants = new List <Node>(n.Descendants); sortedDescendants.Sort((d1, d2) => { return(d1.Row < d2.Row ? -1 : 1); }); if (possibleDescOnSameRow.Any() && (AreSortedByTime(sortedDescendants) || possibleDescOnSameRow.Min(d => d.Row) == sortedDescendants.First().Row)) { Node descOnSameRow = possibleDescOnSameRow.Aggregate((n1, n2) => (n1.Row < n2.Row) ? n1 : n2); n.Row = descOnSameRow.Row; descOnSameRow.HasPredecessorOnSameRow = true; } else { int i; for (i = 0; i < LastOnRow.Count; i++) { if ((LastOnRow[i].DeployedPredecessors == LastOnRow[i].Predecessors.Count) && LastOnRow[i].HasPredecessorOnSameRow == false) { break; } } n.Row = i; } n.Descendants.ForEach(d => d.DeployedPredecessors++); Add(n); } return(Result); }
/// <summary> /// Initializes a new instance of the <see cref = "Repository" /> class. /// <para>For a standard repository, <paramref name="path"/> should point to the ".git" folder. For a bare repository, <paramref name="path"/> should directly point to the repository folder.</para> /// </summary> /// <param name = "path">The path to the git repository to open.</param> public Repository(string path) { Ensure.ArgumentNotNullOrEmptyString(path, "path"); var res = NativeMethods.git_repository_open(out handle, PosixPathHelper.ToPosix(path)); Ensure.Success(res); isBare = NativeMethods.git_repository_is_bare(handle); if (!isBare) { index = new Index(this); } commits = new CommitCollection(this); refs = new ReferenceCollection(this); branches = new BranchCollection(this); tags = new TagCollection(this); }
public static BranchCollection GetAllItem(int CompanyID) { BranchCollection collection = new BranchCollection(); var sqlParams = new SqlParameter[] { new SqlParameter("@CompanyID", CompanyID), }; using (var reader = SqlHelper.ExecuteReader("Branch_GetAll", sqlParams)) { while (reader.Read()) { Branch obj = new Branch(); obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }
/// <summary> /// Initializes a new instance of the <see cref = "Repository" /> class. /// <para>For a standard repository, <paramref name="path"/> should point to the ".git" folder. For a bare repository, <paramref name="path"/> should directly point to the repository folder.</para> /// </summary> /// <param name = "path">The path to the git repository to open.</param> public Repository(string path) { Ensure.ArgumentNotNullOrEmptyString(path, "path"); var res = NativeMethods.git_repository_open(out handle, PosixPathHelper.ToPosix(path)); Ensure.Success(res); string normalizedPath = NativeMethods.git_repository_path(handle).MarshallAsString(); string normalizedWorkDir = NativeMethods.git_repository_workdir(handle).MarshallAsString(); Info = new RepositoryInformation(this, normalizedPath, normalizedWorkDir, normalizedWorkDir == null); if (!Info.IsBare) index = new Index(this); commits = new CommitCollection(this); refs = new ReferenceCollection(this); branches = new BranchCollection(this); tags = new TagCollection(this); }
public static BranchCollection GetbyUser(string CreatedUser, int CompanyID) { BranchCollection collection = new BranchCollection(); Branch obj; var sqlParams = new SqlParameter[] { new SqlParameter("@CreatedUser", CreatedUser), new SqlParameter("@CompanyID", CompanyID), }; using (var reader = SqlHelper.ExecuteReader("Branch_GetAll_byUser", sqlParams)) { while (reader.Read()) { obj = GetItemFromReader(reader); collection.Add(obj); } } return(collection); }
private void GetBranches() { if (FilteringHelper.Instance.SelectedRepositories == null || !FilteringHelper.Instance.SelectedRepositories.Any() || FilteringHelper.Instance.SelectedRepositories.First() == null) { return; } if (BranchCollection != null && BranchCollection.Any()) { BranchCollection.Clear(); } using (var session = DbService.Instance.SessionFactory.OpenSession()) { Repository repository = null; if (BranchCollection != null && BranchCollection.Any()) { BranchCollection.Clear(); } if (string.IsNullOrEmpty(FilteringHelper.Instance.SelectedRepositories.First())) { var branches = session.QueryOver <Branch>().List <Branch>(); branches.ForEach(branch => BranchCollection.Add(branch.Name)); } else { var branches = session.QueryOver <Branch>() .JoinAlias(branch => branch.Repository, () => repository, JoinType.InnerJoin) .Where(() => repository.Name == FilteringHelper.Instance.SelectedRepositories.First()) .TransformUsing(Transformers.DistinctRootEntity) .List <Branch>(); branches.ForEach(branch => BranchCollection.Add(branch.Name)); } } }
private void Do(object state) { var kv = (KeyValuePair <FullKey, Branch>)state; Branch branch = kv.Value; bool isFall = false; branch.WaitFall(); if (branch.NodeState == NodeState.None) { List = new BranchCollection(kv); } else { branch.Fall(Level, Token, new Params(WalkMethod.Current, WalkAction.None, null, true)); branch.WaitFall(); isFall = true; if (branch.NodeState == NodeState.None) { List = new BranchCollection(kv); } else { List = new BranchCollection(); List.Add(kv); if (branch.NodeState == NodeState.Overflow) { Split(0); } } } if (Index + 1 >= Helpers.Length) { return; } var h = Helpers[Index + 1]; h.Task.Wait(); if (branch.NodeState == NodeState.Underflow || h.List[0].Value.NodeState == NodeState.Underflow) { if (!isFall) { branch.Fall(Level, Token, new Params(WalkMethod.Current, WalkAction.None, null, true)); branch.WaitFall(); } if (h.List[0].Value.Cache.OperationCount > 0) { h.List[0].Value.Fall(Level, Token, new Params(WalkMethod.Current, WalkAction.None, null, true)); h.List[0].Value.WaitFall(); } Debug.Assert(h.List[0].Value.Cache.OperationCount == 0); Merge(h.List[0].Value.Node); h.List.RemoveAt(0); } if (List[List.Count - 1].Value.NodeState == NodeState.Overflow) { Split(List.Count - 1); } }
private void UpdateBranches() { branches = GitManager.Repository.Branches; }
private void DoBranch(Branch branch, BranchCollection branchCollection) { bool isHead = branch.IsCurrentRepositoryHead; GUIContent titleContent = GitGUI.GetTempContent(branch.FriendlyName); if (isHead) { titleContent.text += " (HEAD)"; } if (branch.IsRemote) { titleContent.image = GitGUI.IconContentTex("ToolHandleGlobal"); } GUILayout.Label(titleContent, isHead ? "IN BigTitle" : "ShurikenModuleTitle", GUILayout.ExpandWidth(true)); int selectedRemote = Array.FindIndex(remoteCacheList, e => e.Remote == branch.Remote); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(GitGUI.GetTempContent("Remote")); if (remoteNames != null) { EditorGUI.BeginChangeCheck(); int newSelectedRemote = EditorGUILayout.Popup(selectedRemote, remoteNames); if (EditorGUI.EndChangeCheck() && selectedRemote != newSelectedRemote) { branchCollection.Update(branch, (u) => { u.Remote = remoteCacheList[newSelectedRemote].Name; u.UpstreamBranch = branch.CanonicalName; }); } } else { GUILayout.Button(GitGUI.GetTempContent("No Remotes")); } EditorGUILayout.EndHorizontal(); EditorGUILayout.TextField(GitGUI.GetTempContent("Upstream Branch"), branch.UpstreamBranchCanonicalName); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUI.enabled = remoteCacheList != null && remoteCacheList.Length < selectedRemote; if (GUILayout.Button(GitGUI.GetTempContent("Save", "Send branch changes to selected remote."), EditorStyles.miniButtonLeft)) { branchCollection.Update(branch, (u) => { u.Remote = remoteCacheList[selectedRemote].Name; u.UpstreamBranch = branch.CanonicalName; }); } GUI.enabled = !branch.IsRemote && !isHead; Rect switchButtonRect = GUILayoutUtility.GetRect(GitGUI.GetTempContent("Switch"), EditorStyles.miniButtonMid); if (GUI.Button(switchButtonRect, GitGUI.GetTempContent("Switch"), EditorStyles.miniButtonMid)) { if (externalManager.TakeSwitch()) { gitCallbacks.IssueAssetDatabaseRefresh(); gitManager.MarkDirty(); } else { PopupWindow.Show(switchButtonRect, injectionHelper.CreateInstance <GitCheckoutWindowPopup>(branch)); } } GUI.enabled = !isHead; if (GUILayout.Button(GitGUI.GetTempContent("Delete", branch.IsCurrentRepositoryHead ? "Can not delete head branch" : ""), EditorStyles.miniButtonMid)) { if (EditorUtility.DisplayDialog("Delete Branch", "Are you sure you want do delete a branch? This action can not be undone.", "Delete", "Cancel")) { try { gitManager.Repository.Branches.Remove(branch); gitManager.MarkDirty(true); } catch (Exception e) { logger.LogFormat(LogType.Error, "Could not delete branch: {0}", branch.CanonicalName); logger.LogException(e); } } } GUI.enabled = !branch.IsRemote; if (GUILayout.Button(GitGUI.GetTempContent("Reset", "Reset branch properties."), EditorStyles.miniButtonRight)) { branchCollection.Update(branch, (u) => { u.Remote = ""; u.UpstreamBranch = ""; }); } GUI.enabled = true; GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }
public void Rebuild(BranchCollection branches) { Branches = branches; Map = BuildRanges(); }
/// <summary> /// Initializes a new instance of the <see cref = "Repository" /> class, providing ooptional behavioral overrides through <paramref name="options"/> parameter. /// <para>For a standard repository, <paramref name = "path" /> should either point to the ".git" folder or to the working directory. For a bare repository, <paramref name = "path" /> should directly point to the repository folder.</para> /// </summary> /// <param name = "path"> /// The path to the git repository to open, can be either the path to the git directory (for non-bare repositories this /// would be the ".git" folder inside the working directory) or the path to the working directory. /// </param> /// <param name="options"> /// Overrides to the way a repository is opened. /// </param> public Repository(string path, RepositoryOptions options = null) { Ensure.ArgumentNotNullOrEmptyString(path, "path"); Ensure.Success(NativeMethods.git_repository_open(out handle, path)); RegisterForCleanup(handle); bool isBare = NativeMethods.RepositoryStateChecker(handle, NativeMethods.git_repository_is_bare); Func<Index> indexBuilder = () => new Index(this); if (options != null) { bool isWorkDirNull = string.IsNullOrEmpty(options.WorkingDirectoryPath); bool isIndexNull = string.IsNullOrEmpty(options.IndexPath); if (isWorkDirNull && isIndexNull) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "At least one member of the {0} instance has to be provided.", typeof(RepositoryOptions).Name)); } if (isBare && (isWorkDirNull ^ isIndexNull)) { throw new ArgumentException("When overriding the opening of a bare repository, both RepositoryOptions.WorkingDirectoryPath an RepositoryOptions.IndexPath have to be provided."); } isBare = false; if (!isIndexNull) { indexBuilder = () => new Index(this, options.IndexPath); } if (!isWorkDirNull) { Ensure.Success(NativeMethods.git_repository_set_workdir(handle, options.WorkingDirectoryPath)); } } if (!isBare) { index = indexBuilder(); } commits = new CommitCollection(this); refs = new ReferenceCollection(this); branches = new BranchCollection(this); tags = new TagCollection(this); info = new Lazy<RepositoryInformation>(() => new RepositoryInformation(this, isBare)); config = new Lazy<Configuration>(() => new Configuration(this)); remotes = new Lazy<RemoteCollection>(() => new RemoteCollection(this)); odb = new Lazy<ObjectDatabase>(() => new ObjectDatabase(this)); diff = new Diff(this); }
private void Do(object state) { var kv = (KeyValuePair<FullKey, Branch>)state; Branch branch = kv.Value; bool isFall = false; branch.WaitFall(); if (branch.NodeState == NodeState.None) List = new BranchCollection(kv); else { branch.Fall(Level, Token, new Params(WalkMethod.Current, WalkAction.None, null, true)); branch.WaitFall(); isFall = true; if (branch.NodeState == NodeState.None) List = new BranchCollection(kv); else { List = new BranchCollection(); List.Add(kv); if (branch.NodeState == NodeState.Overflow) Split(0); } } if (Index + 1 >= Helpers.Length) return; var h = Helpers[Index + 1]; h.Task.Wait(); if (branch.NodeState == NodeState.Underflow || h.List[0].Value.NodeState == NodeState.Underflow) { if (!isFall) { branch.Fall(Level, Token, new Params(WalkMethod.Current, WalkAction.None, null, true)); branch.WaitFall(); } if (h.List[0].Value.Cache.OperationCount > 0) { h.List[0].Value.Fall(Level, Token, new Params(WalkMethod.Current, WalkAction.None, null, true)); h.List[0].Value.WaitFall(); } Debug.Assert(h.List[0].Value.Cache.OperationCount == 0); Merge(h.List[0].Value.Node); h.List.RemoveAt(0); } if (List[List.Count - 1].Value.NodeState == NodeState.Overflow) Split(List.Count - 1); }
/* * private void ShowRemoteRepoList() * { * StringBuilder sb = new StringBuilder(); * String path = ""; * foreach (var folderPath in SelectedItemPaths) * { * path = folderPath; * break; * } * * Repository repo = new Repository(path); * BranchCollection bc = repo.Branches; * foreach (Remote b in repo.Network.Remotes) * { * sb.AppendLine( b.Name + ": " + b.Url ); * } * MessageBox.Show("Remote repositories:\n" + sb.ToString() ); * } */ private void CreateSubMenuRemoteRepoList(ToolStripMenuItem menu) { //List<ToolStripMenuItem> StringBuilder sb = new StringBuilder(); String path = null; String strError = " error:"; foreach (var folderPath in SelectedItemPaths) { path = folderPath; break; } ToolStripMenuItem item = null; try { if (FolderPath == null) { //MessageBox.Show("FolderPath: null"); strError += " FolderPath=null"; } else { //MessageBox.Show("FolderPath: " + FolderPath); if (path == null) { path = FolderPath; } } if (path != null) { Repository repo = new Repository(path); BranchCollection bc = repo.Branches; foreach (Remote b in repo.Network.Remotes) { item = new ToolStripMenuItem(); item.Text = b.Name + ": " + b.Url; item.Click += (sender, args) => { System.Diagnostics.Process.Start(b.Url); }; menu.DropDownItems.Add(item); //sb.AppendLine(b.Name + ": " + b.Url); } } } catch (RepositoryNotFoundException e) { strError += " RepositoryNotFoundException"; Console.WriteLine("Repository not found in folder " + path + "\n" + e.ToString()); } catch (Exception e) { strError += " Exception:" + e.Message; Console.WriteLine("Something wrong with path: " + path + "\n" + e.ToString()); } if (item == null) { item = new ToolStripMenuItem(); item.Text = "no remote branches for path " + (path == null ? "null" : path); // +", " + strError; menu.DropDownItems.Add(item); } //menu.ShowDropDown(); //MessageBox.Show("Remote repositories:\n" + sb.ToString()); }