public LogEntry CopyTree(IGitTreeModifier treeBuilder, ITfsWorkspace workspace) { var startTime = DateTime.Now; var itemsCopied = 0; var maxChangesetId = 0; var tfsTreeEntries = GetTree().ToArray(); if (tfsTreeEntries.Length == 0) { maxChangesetId = _changeset.ChangesetId; } else { workspace.Get(_changeset.ChangesetId); foreach (var entry in tfsTreeEntries) { Add(entry.Item, entry.FullName, treeBuilder, workspace); maxChangesetId = Math.Max(maxChangesetId, entry.Item.ChangesetId); itemsCopied++; if (DateTime.Now - startTime > TimeSpan.FromSeconds(30)) { _stdout.WriteLine("{0} objects created...", itemsCopied); startTime = DateTime.Now; } } } return(MakeNewLogEntry(maxChangesetId == _changeset.ChangesetId ? _changeset : _tfs.GetChangeset(maxChangesetId))); }
public void Apply(ITfsWorkspace workspace) { workspace.Edit(Path); workspace.Rename(Path, PathTo, Score); var workspaceFile = workspace.GetLocalPath(PathTo); _repository.GetBlob(NewSha, workspaceFile); }
private void Add(IItem item, string pathInGitRepo, GitIndexInfo index, ITfsWorkspace workspace) { if (item.DeletionId == 0) { index.Update(Mode.NewFile, pathInGitRepo, workspace.GetLocalPath(pathInGitRepo)); } }
public void Apply(ITfsWorkspace workspace) { workspace.Edit(_path); workspace.Rename(_path, _pathTo); var workspaceFile = workspace.GetLocalPath(_pathTo); _repository.GetBlob(_newSha, workspaceFile); }
public LogEntry CopyTree(GitIndexInfo index, ITfsWorkspace workspace) { var startTime = DateTime.Now; var itemsCopied = 0; var maxChangesetId = 0; var tfsTreeEntries = GetTree().ToArray(); if (tfsTreeEntries.Length == 0) { maxChangesetId = _changeset.ChangesetId; } else { workspace.Get(_changeset.ChangesetId); foreach (var entry in tfsTreeEntries) { Add(entry.Item, entry.FullName, index, workspace); maxChangesetId = Math.Max(maxChangesetId, entry.Item.ChangesetId); itemsCopied++; if (DateTime.Now - startTime > TimeSpan.FromSeconds(30)) { _stdout.WriteLine("{0} objects created...", itemsCopied); startTime = DateTime.Now; } } } return MakeNewLogEntry(maxChangesetId == _changeset.ChangesetId ? _changeset : _tfs.GetChangeset(maxChangesetId)); }
public void Apply(ITfsWorkspace workspace) { var workspaceFile = workspace.GetLocalPath(Path); Repository.CopyBlob(NewSha, workspaceFile); workspace.Add(Path); }
private void PendChangesToWorkspace(string head, string parent, ITfsWorkspace workspace) { foreach (var change in Repository.GetChangedFiles(parent, head)) { change.Apply(workspace); } }
private void Apply(IChange change, GitIndexInfo index, ITfsWorkspace workspace, IDictionary <string, GitObject> initialTree) { // If you make updates to a dir in TF, the changeset includes changes for all the children also, // and git doesn't really care if you add or delete empty dirs. if (change.Item.ItemType == TfsItemType.File) { var pathInGitRepo = GetPathInGitRepo(change.Item.ServerItem, workspace.Remote, initialTree); if (pathInGitRepo == null || Summary.Remote.ShouldSkip(pathInGitRepo)) { return; } if (change.ChangeType.IncludesOneOf(TfsChangeType.Rename)) { Rename(change, pathInGitRepo, index, workspace, initialTree); } else if (change.ChangeType.IncludesOneOf(TfsChangeType.Delete)) { Delete(pathInGitRepo, index, initialTree); } else { Update(change, pathInGitRepo, index, workspace, initialTree); } } }
public LogEntry Apply(string lastCommit, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary <string, GitObject> initialTree, Action <Exception> ignorableErrorHandler) { if (initialTree.Empty()) { Summary.Remote.Repository.GetObjects(lastCommit, initialTree); } var remoteRelativeLocalPath = GetPathRelativeToWorkspaceLocalPath(workspace); var resolver = new PathResolver(Summary.Remote, remoteRelativeLocalPath, initialTree); var sieve = new ChangeSieve(_changeset, resolver); if (sieve.RenameBranchCommmit) { IsRenameChangeset = true; } _changeset.Get(workspace, sieve.GetChangesToFetch(), ignorableErrorHandler); var forceGetChanges = lastCommit == null; foreach (var change in sieve.GetChangesToApply(forceGetChanges)) { ignorableErrorHandler.Catch(() => { Apply(change, treeBuilder, workspace, initialTree); }); } return(MakeNewLogEntry()); }
public void Get(ITfsWorkspace workspace, IEnumerable <IChange> changes) { foreach (var change in changes) { var item = (UnshelveItem)change.Item; item.Get(workspace); } }
private long Checkin(string head, string parent, ITfsWorkspace workspace, CheckinOptions options, string sourceTfsPath) { PendChangesToWorkspace(head, parent, workspace); if (!string.IsNullOrWhiteSpace(sourceTfsPath)) { workspace.Merge(sourceTfsPath, TfsRepositoryPath); } return(workspace.Checkin(options)); }
private string GetPathRelativeToWorkspaceLocalPath(ITfsWorkspace workspace) { if (workspace.Remote.MatchesUrlAndRepositoryPath(Summary.Remote.TfsUrl, Summary.Remote.TfsRepositoryPath)) { return(""); } return(string.IsNullOrEmpty(Summary.Remote.TfsRepositoryPath) ? "" : Summary.Remote.Prefix); }
public TfsFileSystem(ITfsWorkspace workspace, string path) : base(path) { if (workspace == null) { throw new ArgumentNullException("workspace"); } Workspace = workspace; }
public LogEntry Apply(string lastCommit, GitIndexInfo index, ITfsWorkspace workspace) { var initialTree = Summary.Remote.Repository.GetObjects(lastCommit); workspace.Get(_changeset); foreach (var change in Sort(_changeset.Changes)) { Apply(change, index, workspace, initialTree); } return MakeNewLogEntry(); }
public LogEntry Apply(string lastCommit, GitIndexInfo index, ITfsWorkspace workspace) { var initialTree = workspace.Remote.Repository.GetObjects(lastCommit); workspace.Get(_changeset); foreach (var change in Sort(_changeset.Changes)) { Apply(change, index, workspace, initialTree); } return(MakeNewLogEntry()); }
private void Update(ApplicableChange change, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree) { var localPath = workspace.GetLocalPath(change.GitPath); if (File.Exists(localPath)) { treeBuilder.Add(change.GitPath, localPath, change.Mode); } else { _stdout.WriteLine("Cannot checkout file '{0}' from TFS. Skip it", change.GitPath); } }
private void Rename(IChange change, string pathInGitRepo, GitIndexInfo index, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree) { var oldPath = GetPathInGitRepo(GetPathBeforeRename(change.Item), initialTree); if (oldPath != null) { Delete(oldPath, index, initialTree); } if (!change.ChangeType.IncludesOneOf(TfsChangeType.Delete)) { Update(change, pathInGitRepo, index, workspace, initialTree); } }
public LogEntry Apply(string lastCommit, IGitTreeModifier treeBuilder, ITfsWorkspace workspace) { var initialTree = Summary.Remote.Repository.GetObjects(lastCommit); var resolver = new PathResolver(Summary.Remote, initialTree); var sieve = new ChangeSieve(_changeset, resolver); workspace.Get(_changeset.ChangesetId, sieve.GetChangesToFetch()); foreach (var change in sieve.GetChangesToApply()) { Apply(change, treeBuilder, workspace, initialTree); } return MakeNewLogEntry(); }
public LogEntry Apply(string lastCommit, IGitTreeModifier treeBuilder, ITfsWorkspace workspace) { var initialTree = Summary.Remote.Repository.GetObjects(lastCommit); var resolver = new PathResolver(Summary.Remote, initialTree); var sieve = new ChangeSieve(_changeset, resolver); workspace.Get(_changeset.ChangesetId, sieve.GetChangesToFetch()); foreach (var change in sieve.GetChangesToApply()) { Apply(change, treeBuilder, workspace, initialTree); } return(MakeNewLogEntry()); }
private void Update(ApplicableChange change, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary <string, GitObject> initialTree) { var localPath = workspace.GetLocalPath(change.GitPath); if (File.Exists(localPath)) { treeBuilder.Add(change.GitPath, localPath, change.Mode); } else { Trace.TraceInformation("Cannot checkout file '{0}' from TFS. Skip it", change.GitPath); } }
private void Apply(ApplicableChange change, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree) { switch (change.Type) { case ChangeType.Update: Update(change, treeBuilder, workspace, initialTree); break; case ChangeType.Delete: Delete(change.GitPath, treeBuilder, initialTree); break; default: throw new NotImplementedException("Unsupported change type: " + change.Type); } }
public LogEntry Apply(string lastCommit, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree, Action<Exception> ignorableErrorHandler) { if (initialTree.Empty()) Summary.Remote.Repository.GetObjects(lastCommit, initialTree); var resolver = new PathResolver(Summary.Remote, initialTree); var sieve = new ChangeSieve(_changeset, resolver); _changeset.Get(workspace, sieve.GetChangesToFetch(), ignorableErrorHandler); foreach (var change in sieve.GetChangesToApply()) { ignorableErrorHandler.Catch(() => { Apply(change, treeBuilder, workspace, initialTree); }); } return MakeNewLogEntry(); }
public LogEntry Apply(string lastCommit, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary <string, GitObject> initialTree) { if (initialTree.Empty()) { Summary.Remote.Repository.GetObjects(lastCommit, initialTree); } var resolver = new PathResolver(Summary.Remote, initialTree); var sieve = new ChangeSieve(_changeset, resolver); _changeset.Get(workspace, sieve.GetChangesToFetch()); foreach (var change in sieve.GetChangesToApply()) { Apply(change, treeBuilder, workspace, initialTree); } return(MakeNewLogEntry()); }
private void Apply(ApplicableChange change, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary <string, GitObject> initialTree) { switch (change.Type) { case ChangeType.Update: Update(change, treeBuilder, workspace, initialTree); break; case ChangeType.Delete: Delete(change.GitPath, treeBuilder, initialTree); break; default: throw new NotImplementedException("Unsupported change type: " + change.Type); } }
private void Update(ApplicableChange change, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary <string, GitObject> initialTree) { var localPath = workspace.GetLocalPath(change.GitPath); if (File.Exists(localPath)) { if (new System.IO.FileInfo(localPath).Length > 50 * 1024 * 1024) { throw new Exception($"File too large for github {localPath}"); } treeBuilder.Add(change.GitPath, localPath, change.Mode); } else { Trace.TraceInformation("Cannot checkout file '{0}' from TFS. Skip it", change.GitPath); } }
public LogEntry Apply(string lastCommit, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree, Action<Exception> ignorableErrorHandler) { if (initialTree.Empty()) Summary.Remote.Repository.GetObjects(lastCommit, initialTree); var remoteRelativeLocalPath = GetPathRelativeToWorkspaceLocalPath(workspace); var resolver = new PathResolver(Summary.Remote, remoteRelativeLocalPath, initialTree); var sieve = new ChangeSieve(_changeset, resolver); if (sieve.RenameBranchCommmit) { IsRenameChangeset = true; } _changeset.Get(workspace, sieve.GetChangesToFetch(), ignorableErrorHandler); var forceGetChanges = lastCommit == null; foreach (var change in sieve.GetChangesToApply(forceGetChanges)) { ignorableErrorHandler.Catch(() => { Apply(change, treeBuilder, workspace, initialTree); }); } return MakeNewLogEntry(); }
public LogEntry Apply(string lastCommit, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary <string, GitObject> initialTree, Action <Exception> ignorableErrorHandler, FileFilter filters) { if (initialTree.Empty()) { //add mappings to the resolver _mappingsFile.Mappings.ForEach(m => { if (!initialTree.ContainsKey(m.TfsPath)) { initialTree.Add(m.TfsPath, new GitObject() { Path = m.LocalPath }); } }); Summary.Remote.Repository.GetObjects(lastCommit, initialTree); } var remoteRelativeLocalPath = GetPathRelativeToWorkspaceLocalPath(workspace); var resolver = new PathResolver(Summary.Remote, remoteRelativeLocalPath, initialTree); var sieve = new ChangeSieve(_changeset, resolver, filters); if (sieve.RenameBranchCommmit) { IsRenameChangeset = true; } _changeset.Get(workspace, sieve.GetChangesToFetch(), ignorableErrorHandler); var forceGetChanges = lastCommit == null; foreach (var change in sieve.GetChangesToApply(forceGetChanges)) { ignorableErrorHandler.Catch(() => { Apply(change, treeBuilder, workspace, initialTree); }); } return(MakeNewLogEntry()); }
public LogEntry CopyTree(IGitTreeModifier treeBuilder, ITfsWorkspace workspace) { var startTime = DateTime.Now; var itemsCopied = 0; var maxChangesetId = 0; var tfsTreeEntries = GetTree().ToArray(); if (tfsTreeEntries.Length == 0) { maxChangesetId = _changeset.ChangesetId; } else { workspace.Get(_changeset.ChangesetId); foreach (var entry in tfsTreeEntries) { var tfsPath = entry.FullName; if (!string.IsNullOrEmpty(Summary.Remote.TfsRepositoryPath) && entry.Item.ServerItem.StartsWith(Summary.Remote.TfsRepositoryPath)) { tfsPath = entry.Item.ServerItem.Substring(Summary.Remote.TfsRepositoryPath.Length); } while (tfsPath.StartsWith("/")) { tfsPath = tfsPath.Substring(1); } Add(entry.Item, entry.FullName, tfsPath, treeBuilder, workspace); maxChangesetId = Math.Max(maxChangesetId, entry.Item.ChangesetId); itemsCopied++; if (DateTime.Now - startTime > TimeSpan.FromSeconds(30)) { Trace.TraceInformation("{0} objects created...", itemsCopied); startTime = DateTime.Now; } } } return(MakeNewLogEntry(maxChangesetId == _changeset.ChangesetId ? _changeset : _tfs.GetChangeset(maxChangesetId))); }
private void Apply(IChange change, GitIndexInfo index, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree) { // If you make updates to a dir in TF, the changeset includes changes for all the children also, // and git doesn't really care if you add or delete empty dirs. if (change.Item.ItemType == TfsItemType.File) { var pathInGitRepo = GetPathInGitRepo(change.Item.ServerItem, initialTree); if (pathInGitRepo == null || Summary.Remote.ShouldSkip(pathInGitRepo)) return; if (change.ChangeType.IncludesOneOf(TfsChangeType.Rename)) { Rename(change, pathInGitRepo, index, workspace, initialTree); } else if (change.ChangeType.IncludesOneOf(TfsChangeType.Delete)) { Delete(pathInGitRepo, index, initialTree); } else { Update(change, pathInGitRepo, index, workspace, initialTree); } } }
private void Add(IItem item, string pathInGitRepo, IGitTreeModifier treeBuilder, ITfsWorkspace workspace) { if (item.DeletionId == 0) { treeBuilder.Add(pathInGitRepo, workspace.GetLocalPath(pathInGitRepo), LibGit2Sharp.Mode.NonExecutableFile); } }
private long Checkin(string head, string parent, ITfsWorkspace workspace) { PendChangesToWorkspace(head, parent, workspace); return workspace.Checkin(); }
private void Shelve(string shelvesetName, string head, TfsChangesetInfo parentChangeset, ITfsWorkspace workspace) { foreach (var change in Repository.GetChangedFiles(parentChangeset.GitCommit, head)) { change.Apply(workspace); } workspace.Shelve(shelvesetName); }
private void Update(IChange change, string pathInGitRepo, GitIndexInfo index, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree) { if (change.Item.DeletionId == 0) { index.Update( GetMode(change, initialTree, pathInGitRepo), pathInGitRepo, workspace.GetLocalPath(pathInGitRepo) ); } }
private void Update(ApplicableChange change, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree) { treeBuilder.Add(change.GitPath, workspace.GetLocalPath(change.GitPath), change.Mode); }
private void PendChangesToWorkspace(string head, TfsChangesetInfo parentChangeset, ITfsWorkspace workspace) { foreach (var change in Repository.GetChangedFiles(parentChangeset.GitCommit, head)) { change.Apply(workspace); } }
public void Get(ITfsWorkspace workspace, IEnumerable <IChange> changes, Action <Exception> ignorableErrorHandler) { throw new NotImplementedException(); }
private void Rename(IChange change, string pathInGitRepo, GitIndexInfo index, ITfsWorkspace workspace, IDictionary <string, GitObject> initialTree) { var oldPath = GetPathInGitRepo(GetPathBeforeRename(change.Item), workspace.Remote, initialTree); if (oldPath != null) { Delete(oldPath, index, initialTree); } if (!change.ChangeType.IncludesOneOf(TfsChangeType.Delete)) { Update(change, pathInGitRepo, index, workspace, initialTree); } }
public void Get(ITfsWorkspace workspace, IEnumerable<IChange> changes) { workspace.Get(this.ChangesetId, changes); }
private void Shelve(string shelvesetName, string head, TfsChangesetInfo parentChangeset, bool evaluateCheckinPolicies, ITfsWorkspace workspace) { PendChangesToWorkspace(head, parentChangeset, workspace); workspace.Shelve(shelvesetName, evaluateCheckinPolicies); }
private long CheckinTool(string head, TfsChangesetInfo parentChangeset, ITfsWorkspace workspace) { PendChangesToWorkspace(head, parentChangeset.GitCommit, workspace); return(workspace.CheckinTool(() => Repository.GetCommitMessage(head, parentChangeset.GitCommit))); }
private long Checkin(string head, TfsChangesetInfo parentChangeset, ITfsWorkspace workspace) { PendChangesToWorkspace(head, parentChangeset, workspace); return(workspace.Checkin()); }
public void Get(ITfsWorkspace workspace, IEnumerable <IChange> changes) { workspace.Get(this.ChangesetId, changes); }
public TfsFileSystem(ITfsWorkspace workspace, string path) : base(path) { Workspace = workspace; }
public void Apply(ITfsWorkspace workspace) { workspace.Delete(Path); }
private void Shelve(string shelvesetName, string head, TfsChangesetInfo parentChangeset, CheckinOptions options, bool evaluateCheckinPolicies, ITfsWorkspace workspace) { PendChangesToWorkspace(head, parentChangeset.GitCommit, workspace); workspace.Shelve(shelvesetName, evaluateCheckinPolicies, options); }
private long Checkin(string head, TfsChangesetInfo parentChangeset, ITfsWorkspace workspace) { foreach (var change in Repository.GetChangedFiles(parentChangeset.GitCommit, head)) { change.Apply(workspace); } return workspace.Checkin(); }
private int Checkin(string head, string parent, ITfsWorkspace workspace, CheckinOptions options, string sourceTfsPath) { PendChangesToWorkspace(head, parent, workspace); if (!string.IsNullOrWhiteSpace(sourceTfsPath)) workspace.Merge(sourceTfsPath, TfsRepositoryPath); return workspace.Checkin(options); }
private long CheckinTool(string head, TfsChangesetInfo parentChangeset, ITfsWorkspace workspace) { PendChangesToWorkspace(head, parentChangeset.GitCommit, workspace); return workspace.CheckinTool(() => Repository.GetCommitMessage(head, parentChangeset.GitCommit)); }
public void Get(ITfsWorkspace workspace, IEnumerable<IChange> changes, Action<Exception> ignorableErrorHandler) { workspace.Get(this.ChangesetId, changes); }
private void Shelve(string shelvesetName, string head, TfsChangesetInfo parentChangeset, bool evaluateCheckinPolicies, ITfsWorkspace workspace) { PendChangesToWorkspace(head, parentChangeset.GitCommit, workspace); workspace.Shelve(shelvesetName, evaluateCheckinPolicies, () => Repository.GetCommitMessage(head, parentChangeset.GitCommit)); }
public void Get(ITfsWorkspace workspace, IEnumerable <IChange> changes, Action <Exception> ignorableErrorHandler) { workspace.Get(this.ChangesetId, changes); }
private void Update(IChange change, string pathInGitRepo, GitIndexInfo index, ITfsWorkspace workspace, IDictionary <string, GitObject> initialTree) { if (change.Item.DeletionId == 0) { index.Update( GetMode(change, initialTree, pathInGitRepo), pathInGitRepo, workspace.GetLocalPath(pathInGitRepo) ); } }
public void Apply(ITfsWorkspace workspace) { workspace.Edit(Path); var workspaceFile = workspace.GetLocalPath(Path); _repository.CopyBlob(NewSha, workspaceFile); }