private IGitTfsRemote FindOrInitTfsRemoteOfChangeset(int parentChangesetId, bool mergeChangeset, IRenameResult renameResult, out string omittedParentBranch) { omittedParentBranch = null; IGitTfsRemote tfsRemote; IChangeset parentChangeset = Tfs.GetChangeset(parentChangesetId); //I think you want something that uses GetPathInGitRepo and ShouldSkip. See TfsChangeset.Apply. //Don't know if there is a way to extract remote tfs repository path from changeset datas! Should be better!!! var remote = Repository.ReadAllTfsRemotes().FirstOrDefault(r => parentChangeset.Changes.Any(c => r.GetPathInGitRepo(c.Item.ServerItem) != null)); if (remote != null) { tfsRemote = remote; } else { // If the changeset has created multiple folders, the expected branch folder will not always be the first // so we scan all the changes of type folder to try to detect the first one which is a branch. // In most cases it will change nothing: the first folder is the good one IBranchObject tfsBranch = null; string tfsPath = null; var allBranches = Tfs.GetBranches(true); foreach (var change in parentChangeset.Changes) { tfsPath = change.Item.ServerItem; tfsPath = tfsPath.EndsWith("/") ? tfsPath : tfsPath + "/"; tfsBranch = allBranches.SingleOrDefault(b => tfsPath.StartsWith(b.Path.EndsWith("/") ? b.Path : b.Path + "/")); if (tfsBranch != null) { // we found a branch, we stop here break; } } if (mergeChangeset && tfsBranch != null && string.Equals(Repository.GetConfig(GitTfsConstants.IgnoreNotInitBranches), true.ToString(), StringComparison.InvariantCultureIgnoreCase)) { Trace.TraceInformation("warning: skip not initialized branch for path " + tfsBranch.Path); tfsRemote = null; omittedParentBranch = tfsBranch.Path + ";C" + parentChangesetId; } else if (tfsBranch == null) { Trace.TraceInformation("error: branch not found. Verify that all the folders have been converted to branches (or something else :().\n\tpath {0}", tfsPath); tfsRemote = null; omittedParentBranch = ";C" + parentChangesetId; } else { tfsRemote = InitTfsRemoteOfChangeset(tfsBranch, parentChangeset.ChangesetId, renameResult); if (tfsRemote == null) { omittedParentBranch = tfsBranch.Path + ";C" + parentChangesetId; } } } return(tfsRemote); }
private string FindMergedRemoteAndFetch(int parentChangesetId, bool stopOnFailMergeCommit) { var tfsRemotes = FindTfsRemoteOfChangeset(Tfs.GetChangeset(parentChangesetId)); foreach (var tfsRemote in tfsRemotes.Where(r => string.Compare(r.TfsRepositoryPath, this.TfsRepositoryPath, StringComparison.InvariantCultureIgnoreCase) != 0)) { var fetchResult = tfsRemote.Fetch(stopOnFailMergeCommit); } return(Repository.FindCommitHashByChangesetId(parentChangesetId)); }
private IGitTfsRemote FindOrInitTfsRemoteOfChangeset(int parentChangesetId, bool mergeChangeset, out string omittedParentBranch) { omittedParentBranch = null; IGitTfsRemote tfsRemote; IChangeset parentChangeset = Tfs.GetChangeset(parentChangesetId); //I think you want something that uses GetPathInGitRepo and ShouldSkip. See TfsChangeset.Apply. //Don't know if there is a way to extract remote tfs repository path from changeset datas! Should be better!!! var remote = Repository.ReadAllTfsRemotes().FirstOrDefault(r => parentChangeset.Changes.Any(c => r.GetPathInGitRepo(c.Item.ServerItem) != null)); if (remote != null) { tfsRemote = remote; } else { var tfsPath = parentChangeset.Changes.First().Item.ServerItem; tfsPath = tfsPath.EndsWith("/") ? tfsPath : tfsPath + "/"; var tfsBranch = Tfs.GetBranches(true).SingleOrDefault(b => tfsPath.StartsWith(b.Path.EndsWith("/") ? b.Path : b.Path + "/")); if (mergeChangeset && tfsBranch != null && Repository.GetConfig(GitTfsConstants.IgnoreNotInitBranches) == true.ToString()) { stdout.WriteLine("warning: skip not initialized branch for path " + tfsBranch.Path); tfsRemote = null; omittedParentBranch = tfsBranch.Path + ";C" + parentChangesetId; } else if (tfsBranch == null) { stdout.WriteLine("error: branch not found. Verify that all the folders have been converted to branches (or something else :().\n\tpath {0}", tfsPath); tfsRemote = null; omittedParentBranch = ";C" + parentChangesetId; } else { tfsRemote = InitTfsRemoteOfChangeset(tfsBranch, parentChangeset.ChangesetId); if (tfsRemote == null) { omittedParentBranch = tfsBranch.Path + ";C" + parentChangesetId; } } } return(tfsRemote); }
public void QuickFetch(int changesetId, bool ignoreRestricted, bool printRestrictionHint) { try { ITfsChangeset changeset; if (changesetId < 0) { changeset = GetLatestChangeset(); } else { changeset = Tfs.GetChangeset(changesetId, this); } quickFetch(changeset); } catch (Exception ex) { Trace.WriteLine("Quick fetch failed: " + ex.Message); if (!IgnoreException(ex.Message, ignoreRestricted, printRestrictionHint)) { throw; } } }
public ITfsChangeset GetChangeset(long changesetId) { return(Tfs.GetChangeset((int)changesetId, this)); }
public void QuickFetch(int changesetId) { var changeset = Tfs.GetChangeset(changesetId, this); quickFetch(changeset); }
public ITfsChangeset GetChangeset(int changesetId) { return(Tfs.GetChangeset(changesetId, this)); }